Legends,
I have a requirement to run the script exactly after one hour of completion of dependent script.
Eg: Script B should run after one hour on the completion of Script A.
I got the time stamps using following variables. these scripts runs in autosys
> DATE=`date +%H:%M`
> JOB=`jobhist act abcjob |tail -1 | awk '{print $6}'`
> echo $JOB $DATE
03:23 09:54
> DIFF=`expr $DATE - $JOB`
expr: non-numeric argument
how to get the timestamp difference.
if diff is more than one then run the job, else, wait for one hour.
how to calculate that . please help
JOB=03:23
DATE=09:54
JOB_SECS=$(echo $JOB | awk -F":" '{print $1*60+$2}')
DATE_SECS=$(echo $DATE | awk -F":" '{print $1*60+$2}')
DIFF=$((DATE_SECS-JOB_SECS))
if [ $DIFF -ge 60 ]
then
echo start job B
fi
1 Like
@krishmaths
if [ $DIFF -ge 60 ]
is it seconds or minutes. because you calculated diff in seconds?
Please explain working too
It is calculated in minutes. 09:54 is derived by +%H +%M in your date command.
I'm simply trying to convert hours into minutes (09 * 60) and add minutes portion (+54). This will give the absolute minutes and can be used for finding out the difference.
1 Like
Thanks krishmaths
it worked.