|
Does anyone have a simple but effective script which can be used with If I simply tell the program itself to run on cron, I may get several copies running simultaneously. This program is not smart enough to test whether or not it is already active before firing up another copy of itself. |
|
Yes. All you need to do is to create a simple bash script like this:
Then, run the program on a short cron job, like this:
In this example, I have named the script The script itself also uses the Thanks, but I'm actually trying to keep an SSH tunnel alive for a database connection, and the:
line doesn't seem to work out-of-the-box for The above is a general format applicable to all programs. Specifically for SSH, you should try something like this:
Where the following would be replaced by your information:
To be more aggressive in automatically handling migrations and/or IP changes by ignoring host credentials, add the I'm new to Bash scripting, and have a problem with the watchdog script. My user name is replicounts, and the program that needs an occasional restart is aff.py. The crontab is working fine, and my watchdog.sh script (below) is being executed when it should. But the resulting watchdog.log is:
I manually run the program (in webapps/aff/htdocs) with:
The python3.1 is available interactively in all my directories. Also note:
FYI, my watchdog.sh script is:
What needs to be changed? John cron doesn't operate with the same
Or, you can explicitly set the Hope that helps! For reference, here is cron's environment:
Additionally, cron runs the commands directly from your
And then run the command exactly as it appears in the crontab. |