Skip to content

How to use systemd well

Declarative units, Type=simple preferred, Restart=on-failure, and systemctl status for diagnosis.

systemd without pain

  1. Prefer `Type=simple`

    The process runs in foreground; systemd handles daemonizing. No double-fork code.

  2. Set `Restart=on-failure`

    Services auto-restart on crash. Not on clean exit.

  3. Use `ExecStart` with absolute paths

    Never rely on PATH in units.

  4. Logs via `journalctl -u name -f`

    Live tail without a separate log file.

  5. Timers instead of cron

    OnCalendar=*-*-* 03:00:00 is more precise and logs via journald.