I was making a crontab script for a customer today when I got the inspiration to finally do what I have been wanting to do for a while. I wrote a script to write the script for me. This handy script reads in 4 parameters:
- The working directory (where to cd to)
- A binary file (or command to run)
- A file containing the PID of the process to restart
- An output file to save the script to.
This generates a script that can be run from anywhere, like the crontab which will check to make sure the process is running. It will restart the process if not by running the binary file parameter.
The generated script is based on the Unreal3.2 ircdchk script, with some slight modifications. I hope someone finds it useful… if you do, drop a comment here.