Skip to main content

Command Palette

Search for a command to run...

Auto-restart Crashed Systemd Service

Published
0 min read
Auto-restart Crashed Systemd Service

Systemd is a system and service manager for Linux operating systems. It is designed to be backward compatible with SysV init scripts, and provides a number of features such as parallel startup of system services at boot time, on-demand activation of daemons, or dependency-based service control logic.

Systemd Guide: https://red.ht/2YCMEQl

Origin of this instruction: https://bit.ly/2YJ36hQ

TL;DR

[Unit]
Description=Your Daemon
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service

StartLimitIntervalSec=500
StartLimitBurst=5

[Service]
Restart=on-failure
RestartSec=5s

ExecStart=/path/to/daemon

[Install]
WantedBy=multi-user.target

Set StartLimitIntervalSec, StartLimitBurst, Restart, and RestartSec.

90 views

More from this blog

Hong's Tech Blog

110 posts

The blog is older than you know. I prefer counting from the emergence of one integral anomaly to the emergence of the next, in which case this is the forth version.