A system administrator needs to ensure that a specific process continues to run even if it crashes. The process is started by a systemd service unit. Which approach ensures the process is automatically restarted by systemd, with a delay of 30 seconds after each crash, and does not count restarts towards the failure limit?
Trap 1: Restart=on-failure and RestartSec=30
on-failure only restarts on non-zero exit codes or signals; a clean exit (exit code 0) would not trigger restart.
Trap 2: Restart=always, RestartSec=30, StartLimitIntervalSec=0
Setting StartLimitIntervalSec=0 without StartLimitBurst=0 still uses the default StartLimitBurst value (5), so after 5 restarts the service will stop.
Trap 3: Restart=always and RestartSec=30
Without StartLimitIntervalSec and StartLimitBurst settings, the default restart limits will eventually stop the service after multiple crashes.
- A
Restart=always, RestartSec=30, StartLimitIntervalSec=0, StartLimitBurst=0
These settings disable the restart rate limit and ensure the service restarts every 30 seconds regardless of crash behavior.
- B
Restart=on-failure and RestartSec=30
Why wrong: on-failure only restarts on non-zero exit codes or signals; a clean exit (exit code 0) would not trigger restart.
- C
Restart=always, RestartSec=30, StartLimitIntervalSec=0
Why wrong: Setting StartLimitIntervalSec=0 without StartLimitBurst=0 still uses the default StartLimitBurst value (5), so after 5 restarts the service will stop.
- D
Restart=always and RestartSec=30
Why wrong: Without StartLimitIntervalSec and StartLimitBurst settings, the default restart limits will eventually stop the service after multiple crashes.