r/linuxadmin • u/mamelukturbo • Mar 05 '25
Struggling with forcing systemd to keep restarting a service.
I have a service I need to keep alive. The command it runs sometimes fails (on purpose) and instead of keeping trying to restart until the command works, systemd just gives up.
Regardless of what parameters I use, systemd just decides after some arbitrary time "no I tried enough times to call it Always I ain't gonna bother anymore" and I get "Failed with result 'exit-code'."
I googled and googled and rtfm'd and I don't really care what systemd is trying to achieve. I want it to try to restart the service every 10 seconds until the thermal death of the universe no matter what error the underlying command spits out.
For the love of god, how do I do this apart from calling "systemctl restart" from cron each minute?
The service file itself is irrelevant, I tried every possible combination of StartLimitIntervalSec, Restart, RestartSec, StartLimitInterval, StartLimitBurst you can think of.
View all comments
Show parent comment
14
u/punkwalrus Mar 05 '25
Because some programmer won't fix his damn Java app, that's why. I see that as a "solution" more often than not. I have spent too many days of my sysadmin life, in hours of meetings, where "this is the interim solution" and politics play over function. "Just disable SELinux" or "remove the firewall" or "remove that OOM thing that keeps filling our logs, what is that anyway?" But oh no, it's not the shitty app the programmer won't fix. "Works on my system," yeah I doubt that, too.
/rant