Reputation: 99
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.
Upvotes: 0
Views: 2454
Reputation: 13391
Welcome to StackOverflow. For systemd questions, the Unix & Linux StackExchange site is a more appropriate placeto ask in the future.
It appears that you are looking for StartLimitInterval=60
, which allows you to set the number of seconds to limit by. Around systemd
version 230, this is renamed to StartLimitIntervalSec=
.
This would be combined with StartLimitBurst=5
to set a max of 5 starts per minute.
There's also StartLimitAction
but it default to the value of none
, which already does what you want in this case.
You can find these documented in man systemd.unit
. If you aren't sure where to find documentation on a directive, you can use man systemd.directive
to find where any directive is documented.
Upvotes: 2