The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to log start/stop time of ALL processes bluesky099 UNIX for Advanced & Expert Users 10 12-17-2007 08:01 PM
start time of a terminated process k_chaaya UNIX for Advanced & Expert Users 2 09-03-2006 09:57 PM
to get process start date and time naeem ahmad UNIX for Advanced & Expert Users 2 02-27-2006 01:09 AM
get process start time naeem ahmad High Level Programming 1 02-06-2006 04:40 PM
Working out end time from start + elapsed rik1551 UNIX for Dummies Questions & Answers 4 06-06-2002 01:05 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-16-2007
Registered User
 

Join Date: Mar 2007
Posts: 32
Question Start time/end time and status of crontab job

Is there anyway to get the start time and end time / status of a crontab job which was just completed? Of course, we know the start time of the crontab job since we are scheduling. But I would like to know process start and time recorded somewhere or can be fetched from a command like 'ps'. Please suggest.

-Thambi
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-16-2007
sysgate's Avatar
Unix based
 

Join Date: Nov 2006
Location: /root
Posts: 1,128
Suggestion : put a modification of date command in the start of the script, then in the end of the script and have it append to a log file. Then you'll be able to see the difference. Or : let's say that the crontab will execute /home/user/script.sh --> put "/usr/bin/time -f "{#%e#}" -o timelog -a" in the front, this will write the time for execution of the script in file called "timelog". Then "cat timelog" and the time reported will look something like : {#0.16#}
The other way basically is using merely "time", e.g "time ls -la", which will report :
Quote:
real 0m0.119s
user 0m0.008s
sys 0m0.011s
but I don't think you can use it within cronjob, as it's reporting only to STDOUT, I tried to redirect the output to file - no dice. So /usr/bin/time should do the trick. HTH.
Reply With Quote
  #3 (permalink)  
Old 05-16-2007
Registered User
 

Join Date: Mar 2007
Posts: 32
Thanks for suggestions. Actually , my crontab looks like as follows

00 18 * * 1-6 kdshell/remove_flag_files 1>kdlog/remove_flag_files_`date|awk '{print $2 $3 $4}'`.log 2>&1

They are already redirect the log information into a log file. This is stable existing system. I don't want to touch the script , Moreover , our client won't allow us to touch crontab script at all. So I wanted to know any other possibility without touch existing script. I think this is reason some organzation are going for Autosys or Control-M sechudling tool whould would show the start time and end time of the job in the their logs.

-Thambi
Reply With Quote
  #4 (permalink)  
Old 05-16-2007
Registered User
 

Join Date: May 2002
Posts: 62
At the top & bottom of your script you can place:

echo "Started " `date` >>/tmp/tempfile
// script
// script
// script
echo "Completed " `date` >>/tmp/tempfile

Georgio
Reply With Quote
Google UNIX.COM
Reply

Tags
autosys

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:48 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0