What’s the best tool for automatically handling service restarts on Linux systems?
Posted on 24 May 2012 by Tavis.H
Before diving into any discussion about Linux servers, it is important to first properly define the topic of discussion. For our purposes, a “service” is a daemon, a program that starts when the system boots and remains in the memory, running in the background. It is not a normal practice to restart these services without a good reason, but there are situations that warrant periodic restarts.
There are a few situations when you might want a tool that can automatically restart a daemon running on your dedicated server or VPS:
- You want it to detect crashes and automatically bring the service back up
- Daily restarts as a method of flushing out the system
- Detect errors, such as memory leaks and restart to remedy them
Regardless of the reason, the ultimate goal is the same. You want the server to restart a service without any human intervention. The following tools may be able to help you achieve that goal:
- daemontools – This is a no frills, no thrills tool that you can use to monitor daemons and automatically restart them if one of them goes down. It may not be the most user-friendly tool, but it gets the job done.
- Upstart – The Ubuntu project called Upstart can handle services and is meant as a full replacement for /sbin/init. If you are OK with that, you can also tell it to respawn services that die unexpectedly.
- Supervisor – Unlike upstart, it is not meant to replace init, and unlike daemontools, it is not limited to daemons. You can use supervisor to monitor and control any process. It is simple and uses a command-line or web-based interface.
There are many other tools out there that can manage your daemons. You should first determine what your needs actually are and then evaluate each of these tools based on those needs. Find one that is easy for you to use and that also provides you with the control you need to manage your services.