systemd Cheat Sheet: systemctl, Unit Files, Timers and journalctl
Checked against systemd systemd 262 man pages (latest release v262.2, 5 Nov 2026) on 28 November 2026. Each section links to the official docs it was checked against.
This sheet is for developers who run their own Linux servers and need to keep a process alive, schedule a job or read its logs. It follows the freedesktop.org man pages for systemd 262, the version shown on those pages on 28 November 2026. It was written on macOS, which has no systemd, so every row is marked as checked against the man pages only.
When to use what
Use a service unit for anything that should run all the time and come back after a crash. Set Restart=on-failure explicitly, because the default is no; I only use always for workers that are meant to exit and be restarted. The systemd unit generator gives you a starting file you can then trim.
For scheduled jobs, a timer plus a oneshot service is more work than a crontab line, but you get the job's output in the journal, dependency ordering and Persistent=true to catch up on runs missed while the machine was off (it defaults to false). If you think in cron syntax, run your expression through the crontab translator first and then write the OnCalendar= equivalent, checking it with systemd-analyze calendar.
When you change a unit, edit with systemctl edit so your changes go into a drop-in instead of the packaged file, and remember daemon-reload if you edited files by hand. For logs, journalctl -u name is the start of almost every investigation; add -b, --since or -p err to narrow it. If you'd rather paste a chunk of output somewhere and pick it apart, our log parser handles that, and the Next.js on Hetzner with Docker post shows a real server setup.
Add --user to any of these to talk to your per-user service manager instead of the system one.
sudo systemctl start app.serviceStart a unit now without enabling it at boot
sudo systemctl restart appStop and start the unit, or just start it if it was stopped
sudo systemctl reload-or-restart appReload the config if the service supports it, otherwise restart
sudo systemctl enable --now appCreate the boot-time symlinks from [Install] and start the unit
sudo systemctl disable --now appRemove the boot symlinks and also stop it (without --now it keeps running)
systemctl status appShow state, main PID and the last 10 journal lines
systemctl is-active appExit 0 if the unit is active, for use in scripts
sudo systemctl mask appLink the unit to /dev/null so nothing can start it until you unmask
systemctl list-units --failedList units in the failed state
systemctl list-units --type=serviceList loaded service units only
systemctl cat appPrint the unit file plus every drop-in applied to it
sudo systemctl edit appCreate or edit a drop-in override.conf for the unit
sudo systemctl edit --full appEdit a full copy of the unit file instead of a drop-in
sudo systemctl daemon-reloadReload unit files after editing them on disk by hand
systemctl show -p Restart appPrint one property in machine-readable form (-P prints just the value)
sudo systemctl reset-failed appClear the failed state and the start-rate counter
[Unit] and [Install] options are in https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html. Units you write go in /etc/systemd/system, which overrides packaged units in /usr/lib/systemd/system.
[Unit]
Description=Order API
After=network-online.target
Wants=network-online.targetAfter= only orders start-up; pair it with Wants= or Requires= to pull the unit in
[Service]
ExecStart=/usr/bin/node /srv/api/server.jsThe command to run; only one is allowed unless Type=oneshot
Type=simpleThe default when ExecStart= is set; other values include exec, forking, oneshot and notify
Restart=on-failure
RestartSec=5Restart after a crash, waiting 5 seconds (the defaults are no and 100ms)
ExecStartPre=/usr/bin/node /srv/api/migrate.jsRun a command first; if it fails the unit fails unless prefixed with -
[Install]
WantedBy=multi-user.targetWhat systemctl enable hooks the unit into at boot
Calendar syntax is in https://www.freedesktop.org/software/systemd/man/latest/systemd.time.html. A timer named backup.timer starts backup.service unless you set Unit=.
OnCalendar=*-*-* 03:00:00Run every day at 03:00 local time
OnCalendar=Mon..Fri 09:00Run at 09:00 on weekdays; missing seconds default to 00
OnCalendar=*:0/15Run every 15 minutes, starting on the hour
OnCalendar=weeklyShorthand for Monday 00:00:00; also minutely, hourly, daily, monthly, yearly
OnBootSec=10min
OnUnitActiveSec=1hRun 10 minutes after boot, then an hour after each activation
Persistent=trueCatch up on a run missed while the machine was off (default false)
RandomizedDelaySec=15minAdd a random delay of up to 15 minutes so many hosts don't fire at once
systemd-analyze calendar "Mon..Fri 09:00"Normalise an expression and show when it fires next
systemctl list-timersShow every timer with its last and next run
journalctl -u app -fFollow one unit's log live
journalctl -u app -n 100 --no-pagerPrint the last 100 entries without opening a pager
journalctl -b -1 -u appShow the unit's log from the previous boot
journalctl --since yesterday --until "2026-11-28 09:00"Limit output to a time window
journalctl -p err -bShow error-level messages and worse from this boot
journalctl -u app -g timeoutFilter messages with a regex; an all-lowercase pattern ignores case
journalctl -u app -o jsonPrint one JSON object per entry for piping into other tools
sudo journalctl --vacuum-time=2weeksDelete archived journal files older than two weeks
Worked example: Replace a nightly cron job with a timer
The crontab line 0 3 * * * /srv/bin/backup.sh becomes two files.
# /etc/systemd/system/backup.service
[Unit]
Description=Nightly backup
[Service]
Type=oneshot
ExecStart=/srv/bin/backup.sh
# /etc/systemd/system/backup.timer
[Unit]
Description=Run backup nightly
[Timer]
OnCalendar=*-*-* 03:00:00
Persistent=true
[Install]
WantedBy=timers.target
systemd-analyze calendar "*-*-* 03:00:00"
sudo systemctl daemon-reload
sudo systemctl enable --now backup.timer
systemctl list-timers backup.timer
journalctl -u backup.service -n 50
The service has no [Install] section because the timer starts it; you enable the timer, not the service. systemd-analyze calendar should report the next 03:00 as the next elapse time, which catches typos before you rely on it. list-timers then shows a NEXT column for the timer, and after the first run the job's output is in the journal under backup.service. With Persistent=true, a server that was off at 03:00 runs the backup soon after it boots. I wrote this on macOS without systemd, so no output is shown.
Common mistakes
Writing
After=postgresql.serviceand assuming it starts Postgres.After=only sets order. AddWants=orRequires=for the same unit if you need it started.Editing a unit file by hand and wondering why nothing changed after a restart.
Run
systemctl daemon-reloadfirst, or usesystemctl edit, which reloads for you.Leaving out
Restart=and expecting systemd to bring a crashed service back.The default is
Restart=no. SetRestart=on-failureand a sensibleRestartSec=.Running
systemctl disable appand thinking the service has stopped.Disable only removes boot links. Use
disable --now, orstopas well.Enabling the
.serviceof a timer job, so it runs once at boot and never again.Put
[Install]in the.timer, enable the timer, and keep the service as a plain oneshot.
Related cheat sheets
Sources
- https://www.freedesktop.org/software/systemd/man/latest/systemctl.html
- https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html
- https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html
- https://www.freedesktop.org/software/systemd/man/latest/systemd.timer.html
- https://www.freedesktop.org/software/systemd/man/latest/systemd.time.html
- https://www.freedesktop.org/software/systemd/man/latest/journalctl.html
- https://github.com/systemd/systemd/releases
How we research: where our facts come from, how often we re-check them, and why no one can pay for a review or a verdict.