Good day!
How can i check the specific cron job is running? I'm planning to create a script which is do the checking if my cron job is running then if not, the script would execute the cron job again..
Thanks in advance!
God bless you all!
Good day!
How can i check the specific cron job is running? I'm planning to create a script which is do the checking if my cron job is running then if not, the script would execute the cron job again..
Thanks in advance!
God bless you all!
You can write a script that used lsof to track if you script file is in use, or ps to track if an application is running, then choose the appropriate actions based upon the results.
The code below can be used as a base to track if a file is in use and you can adjust the conditional criteria to fit your needs.
#!/bin/bash
SCRIPT="testscript.sh"
if [ -n "$(lsof|grep -i $SCRIPT)" ]; then
echo "$SCRIPT is running"
else
echo "$SCRIPT is not running"
fi
The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.
Join / Linux Training / Board