I am trying to compare two string time to figure out the difference.
I need to find out the start date of a process is running for over certain minutes.
so far I was able to get the process start time and system time. Now I need to figure out the difference between two time in minutes.
Here is my code so far: batch_output_x is the process i am trying to see if its running over certain minutes or not.
#!/usr/bin/ksh
. ~/gateway/bin/gateway_env.sh
VAR=$(ps -ef | grep batch_output_x )
FTP_HOUR=$(echo $VAR|cut -c23-24)
FTP_MIN=$(echo $VAR|cut -c26-27)
FTP_SEC=$(echo $VAR|cut -c29-30)
FTP_HOUR_MIN_SEC=$FTP_HOUR:$FTP_MIN:$FTP_SEC
RUN_TIME=`date +'%H:%M:%S'`
Now how do i get the time difference in minute?
if i do echo on FTP_HOUR_MIN_SEC and RUN_TIME this is what i get.
RUN_TIME=09:28:23
FTP_HOUR_MIN_SEC=09:28:23
---------- Post updated at 10:00 AM ---------- Previous update was at 09:36 AM ----------
I am trying to convert the times into second and then compare with this code
FTP_H_SEC = (($FTP_HOUR*24)*60+$FTP_MIN)*60+$FTP_SEC
But I get an error. to figure out the bug I separated the calculation
FTP_HOUR_SEC = $FTP_HOUR*24
FTP_MIN_SEC = $FTP_HOUR_SEC*60+$FTP_MIN
FTP_H_SEC = $FTP_MIN_SEC*60+$FTP_SEC
echo FTP_SEC=$FTP_H_SEC
but this is the out put i am getting
./chk_process.sh[27]: FTP_HOUR_SEC: not found
./chk_process.sh[28]: FTP_MIN_SEC: not found
./chk_process.sh[29]: FTP_H_SEC: not found