Linux.com

Cron Job

Link to this post 08 Oct 10

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!

Link to this post 08 Oct 10

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

Link to this post 12 Oct 10

Wow! Mr. mfillpot your great..

it helps me a lot..

thank you and god bless you!

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board