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
More on cron and systemd timers
Explain the five cron time fields with examples.BeginnerWhat is different about the environment a cron job runs in?BeginnerWhat is the difference between a user crontab, `/etc/crontab`, `/etc/cron.d/` and `/etc/cron.daily/`?IntermediateHow do you prevent overlapping cron runs and capture output properly?IntermediateWhat is a systemd timer and how does it compare to cron?IntermediateWrite a minimal systemd service and timer that run a backup at 02:30 daily.Intermediate