Systemd service that is always restarted

Just using Restart and RestartSec is not enough: systemd services have start rate limiting enabled by default. If service is started more than StartLimitBurst times in StartLimitIntervalSec seconds is it not permitted to start any more. This parameters are inherited from DefaultStartLimitIntervalSec(default 10s) and DefaultStartLimitBurst(default 5) in systemd-system.conf.

Use systemctl edit foobar.service or manually edit /etc/systemd/system/foobar.service.d/override.conf and run systemctl deamon-reload.

# time to sleep before restarting a service

# StartLimitIntervalSec in recent systemd versions

In recent systemd versions StartLimitInterval was renamed to StartLimitIntervalSec.

You can tune Restart parameter to restart service only on failure, only on uncught signal, etc. Check the manpage.


License: Creative Commons Attribution-ShareAlike License Share: share on reddit share on facebook share on twitter