http://qs321.pair.com?node_id=604332


in reply to Re^2: Auto-restarting script if it dies
in thread Auto-restarting script if it dies

This could be just me, but it seems a bit odd to start one script, and then start another script to check the first script.

Perhaps you could in the checker.pl delete the checkme.txt file (under the line where you declare var $checkme, that way, on start up it's deleted and does not pick up an old version of the file with an old temp file name, as checkme.txt is never deleted any where in your code)

Run the checker.pl script, first time in the loop, file does not exist, starts always_running.pl and creates checkme.txt and then the checker script continues checking checkme.txt.

Just trying to refine the process, I liked the idea lots.

Ant
  • Comment on Re^3: Auto-restarting script if it dies

Replies are listed 'Best First'.
Re^4: Auto-restarting script if it dies
by mojodaddy (Pilgrim) on Mar 13, 2007 at 16:42 UTC
    No, checkme.txt is never deleted; it gets overwritten each time the script starts, though, so the scenario you described never occurs.

    The thing's been working great, too -- almost too well! It was pretty hilarious the first couple of times I tried to restart the script because I'd made a change to the code. It just kept popping back up again! It was like playing whack-a-mole. I've since concluded that stopping the checker first and then stopping the script is the preferred technique!