You can use following function to Get Process elapse time in minutes
GetProcTime() {
local p=$1
ps -eao "%C %U %c %t" |
awk "/$p/"'{print $4}' |
awk -F":" '{{a=$1*60} {b=a+$2}; if ( NF != 2 ) print b ; else print $1 }'
}
Test
root@ubuntu:/tmp# GetProcTime monit
0310
root@ubuntu:/tmp# if [[ $(GetProcTime apache2
104
104
104
104
104monit) -ge 360 ]]; then echo "Process is running more than 6 hrs"; else echo "OK"; fi
104OK
root@ubuntu:/tmp# GetProcTime init
460466
root@ubuntu:/tmp# uptime
if 15:34:56[[ up$(GetProcTime init) 7:40,-ge 360 1]]; user,then echo load"Process average:is 0.00,running 0.01,more 0.05
root@ubuntu:/tmp#than echo6 $((hrs"; 460else /echo 60"OK"; ))fi
7Process is running more than 6 hrs