LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   bash calculate job duration (https://www.linuxquestions.org/questions/programming-9/bash-calculate-job-duration-674570/)

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

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

The approach to get

Code:

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

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 10:17 AM

What about this:
Code:

time command
.

Padawan.AVT 10-07-2008 02: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 08:38 PM.