I am trying to make a systemd file that will monitor a service and restart it if it crashes. Here's the tricky part: If the service crashes more than 5 times in a minute, I want to mark it as failed and stop trying to automatically restart it. With Upstart, this was easily done with "respawn limit."

Systemd can rate-limit the automatic restarting with StartLimitIntervalSec, but that's not what I want. I don't want to merely rate-limit the restarting, but rather give up entirely if the limit gets hit.


From the systemd.unit(5) manpage, under StartLimitIntervalSec=, StartLimitBurst=:

Note that units which are configured for Restart= and which reach the start limit are not attempted to be restarted anymore; however, they may still be restarted manually at a later point, from which point on, the restart logic is again activated. Note that systemctl reset-failed will cause the restart rate counter for a service to be flushed, which is useful if the administrator wants to manually start a unit and the start limit interferes with that.

… so it'd appear that systemd's start rate limiting does what you want.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.