LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-06-2008, 10:11 AM   #1
Padawan.AVT
Member
 
Registered: Feb 2006
Distribution: Gentoo, Slackware, Debian, Suse
Posts: 86

Rep: Reputation: 15
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?
 
Old 10-06-2008, 10:17 AM   #2
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
What about this:
Code:
time command
.
 
Old 10-07-2008, 02:33 AM   #3
Padawan.AVT
Member
 
Registered: Feb 2006
Distribution: Gentoo, Slackware, Debian, Suse
Posts: 86

Original Poster
Rep: Reputation: 15
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl/bash - calculate date in future rose_bud4201 Programming 6 05-10-2009 05:59 AM
Bash script not running within crontab job WrightExposure Linux - General 3 01-23-2007 06:28 PM
Bash Script, calculate output. eldaria Programming 13 07-20-2006 09:26 PM
Bash script and cron job rust8y Linux - General 2 07-08-2006 07:45 AM
Move a job from one bash shell to another? marktaff Linux - General 3 01-13-2006 07:22 PM


All times are GMT -5. The time now is 10:41 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration