Systemd service restart

Hi,

I have a systemd service unit that I configured for automatic restart if the main process exits with a failure. What I want to achieve is that a system reboot is performed if the service has failed more than a given number of times.

You may want to try something with:
You’ll have to define the limits and burst to match what you want to achieve.

StartLimitAction=

Configure an additional action to take if the rate limit configured with StartLimitIntervalSec= and StartLimitBurst= is hit. Takes the same values as the FailureAction=/SuccessAction= settings. If none is set, hitting the rate limit will trigger no action except that the start will not be permitted. Defaults to none.

ref: systemd.unit

2 Likes

Reboot is a last resort option that should not be used normally.
If things go wrong, you may end up in a boot loop.
It is best to try debugging and check logs for troubleshooting.

That’s a good practice; but I’ve ran rolling oS TW and Fedora Server auto-updating everything and rebooting daily for years and never had an update cause a boot-loop :stuck_out_tongue:

Rebooting to apply updates is justified, but not to restart a service.
Even a minor mistake in this startup check can exacerbate the problem.

3 Likes