Skip to content
Advertisement

Do you know how to make the system automatically restart daemon service?

I have made a daemon service in linux server. It is running well. The service file is stargate.service (in /etc/systemd/system).

JavaScript

If by some reasons, the daemon service is die and stop. Do you know how to make the system automatically restart the daemon service ? How to make the daemon service starts if server get rebooted?

Advertisement

Answer

To respawn your service when it fails, add the following to the [Service] block:

JavaScript

If you wish to always restart when your service is killed use Restart=always

The RestartSec value is the delay between restart attempts.

See more info here: https://www.freedesktop.org/software/systemd/man/systemd.service.html

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement