How to automatically restart a systemd service after failure

Linux

With systemd you can configure the service so that it automatically restarts in case it crashes.
It's enough to add the "restart" option to the [Service] stanza within the systemd service configuration file.
See the example below. Of course, you need to reload the systemd file in order to activate it.

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