I'm pretty new to linux scripting but I'm trying to create this script to add into the crontab in order to check if a user process has been running for more than x amount of time.
#! /bin/sh
#This feeds the list of process over 1 hour and strips the colons and sees
#if it is over 12 hours. If so, then mails it to me.
if $(( (ps exo time,pid | grep -v "00:00:" | awk '{print $1}' | sed s/://g) >= 001200 )); then
mailx -s "$(hostname) Long Process Detection" me@example.com
fi
As of right now, it's producing an error that it is missing a ')', but I've looked it over many times and I can't see any unclosed parenthesis. Any help on this would be appreciated. The error reads
"missing ')' (error token is "exo time,pid |grep -v "00:00:" | awk '{print }' | sed s/://g) >= 001200 ")"
The above is solved with shifting the $ inside the opened parenthesis, but it's feeding back an error at the conditional calculation. (i.e. 000106 >= 000010 in my sample).