Run cron job only if it isn't already running

后端 未结 16 954
执笔经年
执笔经年 2020-11-29 14:53

I\'m trying to set up a cron job as a sort of watchdog for a daemon that I\'ve created. If the daemon errors out and fails, I want the cron job to periodically restart it...

16条回答
  •  野性不改
    2020-11-29 15:38

    It's suprising that no one mentioned about run-one. I've solved my problem with this.

     apt-get install run-one
    

    then add run-one before your crontab script

    */20 * * * * * run-one python /script/to/run/awesome.py
    

    Check out this askubuntu SE answer. You can find link to a detailed information there as well.

提交回复
热议问题