How to make sure an application keeps running on Linux

前端 未结 16 1328
清歌不尽
清歌不尽 2020-11-28 18:51

I\'m trying to ensure a script remains running on a development server. It collates stats and provides a web service so it\'s supposed to persist, yet a few times a day, it

16条回答
  •  独厮守ぢ
    2020-11-28 19:42

    I have used from cron "killall -0 programname || /etc/init.d/programname start". kill will error if the process doesn't exist. If it does exist, it'll deliver a null signal to the process (which the kernel will ignore and not bother passing on.)

    This idiom is simple to remember (IMHO). Generally I use this while I'm still trying to discover why the service itself is failing. IMHO a program shouldn't just disappear unexpectedly :)

提交回复
热议问题