-   Programming (
-   -   bash calculate job duration (

Padawan.AVT 10-06-2008 11:11 AM

bash calculate job duration
I need to know how long the particular job is running on my system

The approach to get


start_time=`ps -ef | grep <job_name> | awk '{print $3}'  `
and then substitute from

date today
the $start_time works well until the job started for example, at 23:58 and the script that checks it duration every 10 minutes will run at 00:05 - in this case ps -ef will return the date instead of time and I cannot make accurate calculations.

Any ideas or solutions?

Berhanie 10-06-2008 11:17 AM

What about this:

time command

Padawan.AVT 10-07-2008 03:33 AM

No, for this I need to start a certain process in "time" command. But the process is started as a child from another script and I cannot modify it.

I found better solution

[CODE]ps -eo pid,etime,comm[CODE]

it gives me just what I need

All times are GMT -5. The time now is 06:28 PM.