#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    5
    Rep Power
    0

    timeout for cron job - pls help!


    Hi,

    i have two cron jobs, one running after another ends. If the first cron job keeps executing, and gets hang, i will like to have a timeout for the cron job, so that the next cron job can run. How can I do it?
  2. #2
  3. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Surfside
    Posts
    15
    Rep Power
    0
    why not just separate them by several hours? Set the first one at 2am and the second at 5am. Or swap them around? Or do they both hang? What OS are you using and what shell?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    190
    something similar to this could work (untested):
    Code:
    program &
    echo "kill $?" | at now+1h
    It *could* kill the wrong process though.
    If the program has quit by itself till then, the PID that comes from $? will not be valid anymore. But itīs unlikely that your PIDs wrap over within an hour.

    You could also use a "lock file" for the first process and have the second process check if #1 is still running and if so, kill it.

IMN logo majestic logo threadwatch logo seochat tools logo