Run cron job only if it isn't already running

后端 未结 16 960
执笔经年
执笔经年 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:33

    You can also do it as a one-liner directly in your crontab:

    * * * * * [ `ps -ef|grep -v grep|grep ` -eq 0 ] && 
    

提交回复
热议问题