Interview Prep/Shell Scripting/cron and systemd timers

What do `Type=oneshot`, `RemainAfterExit=` and `SuccessExitStatus=` mean for script services?

AdvancedConceptcron and systemd timers
Answer
  • Type=oneshot: systemd waits for the script to exit; the unit is "activating" while it runs. Right for timer-driven jobs.
  • RemainAfterExit=yes: the unit stays "active" after the script exits; used for one-time setup units (mount, firewall rules), not for timer jobs (a remaining-active unit would not be started again).
  • SuccessExitStatus=1 2: treat these exit codes as success. Useful when a health script uses 1 for "warning" and you do not want the unit marked failed.
[Service]
Type=oneshot
ExecStart=/opt/opskit/bin/opskit-health -q
SuccessExitStatus=1
TimeoutStartSec=2min
All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on cron and systemd timers