Welcome to the Linux Foundation Forum!

Cron Job

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!

Comments

  • Posts: 2,177
    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.
    1. #!/bin/bash
    2. SCRIPT="testscript.sh"
    3. if [ -n "$(lsof|grep -i $SCRIPT)" ]; then
    4. echo "$SCRIPT is running"
    5. else
    6. echo "$SCRIPT is not running"
    7. fi
  • Wow! Mr. mfillpot your great..

    it helps me a lot..

    thank you and god bless you!

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training