How to make sure an application keeps running on Linux

前端 未结 16 1234
清歌不尽
清歌不尽 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:32

    The supervise tool from daemontools would be my preference - but then everything Dan J Bernstein writes is my preference :)

    http://cr.yp.to/daemontools/supervise.html

    You have to create a particular directory structure for your application startup script, but it's very simple to use.

    0 讨论(0)
  • 2020-11-28 19:32

    Check out 'nanny' referenced in Chapter 9 (p197 or thereabouts) of "Unix Hater's Handbook" (one of several sources for the book in PDF).

    0 讨论(0)
  • 2020-11-28 19:37

    Put your run in a loop- so when it exits, it runs again... while(true){ run my app.. }

    0 讨论(0)
  • 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 :)

    0 讨论(0)
提交回复
热议问题