let us suppose I have a cron job like this:
*/15 * * * * /path/to/thedaemon
The daemon (it being a python daemon via
from daemon import runner) will not allow multiple instances of itself, which in itself is quite nice. It one tries to initiate it while the daemon is already running, this is the result:
lockfile.LockTimeout: Timeout waiting to acquire lock for /tmp/thedaemon.pid
Of course the cron job doesn't care - it could keep dry-firing the command routinely so that in the case it is not running, it then starts running. But that is not very elegant.
More elegantly, is there a way to set up the cron job to know if the daemon is running before initiating it? Perhaps a short-hand if-condition?
In short, how do I set up the cron job to ensure that the daemon is running?
If running, do nothing. If not running, initiate.