Skip to content

Menu

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.service

Start a unit now without enabling it at boot

From the docs, not run by us
sudo systemctl restart app

Stop and start the unit, or just start it if it was stopped

From the docs, not run by us
sudo systemctl reload-or-restart app

Reload the config if the service supports it, otherwise restart

From the docs, not run by us
sudo systemctl enable --now app

Create the boot-time symlinks from [Install] and start the unit

From the docs, not run by us
sudo systemctl disable --now app

Remove the boot symlinks and also stop it (without --now it keeps running)

From the docs, not run by us
systemctl status app

Show state, main PID and the last 10 journal lines

From the docs, not run by us
systemctl is-active app

Exit 0 if the unit is active, for use in scripts

From the docs, not run by us
sudo systemctl mask app

Link the unit to /dev/null so nothing can start it until you unmask

From the docs, not run by us
systemctl list-units --failed

List units in the failed state

From the docs, not run by us
systemctl list-units --type=service

List loaded service units only

From the docs, not run by us
systemctl cat app

Print the unit file plus every drop-in applied to it

From the docs, not run by us
sudo systemctl edit app

Create or edit a drop-in override.conf for the unit

From the docs, not run by us
sudo systemctl edit --full app

Edit a full copy of the unit file instead of a drop-in

From the docs, not run by us
sudo systemctl daemon-reload

Reload unit files after editing them on disk by hand

From the docs, not run by us
systemctl show -p Restart app

Print one property in machine-readable form (-P prints just the value)

From the docs, not run by us
sudo systemctl reset-failed app

Clear the failed state and the start-rate counter

From the docs, not run by us

[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.target

After= only orders start-up; pair it with Wants= or Requires= to pull the unit in

Try it: systemd-unit-generatorFrom the docs, not run by us
[Service] ExecStart=/usr/bin/node /srv/api/server.js

The command to run; only one is allowed unless Type=oneshot

From the docs, not run by us
Type=simple

The default when ExecStart= is set; other values include exec, forking, oneshot and notify

From the docs, not run by us
Restart=on-failure RestartSec=5

Restart after a crash, waiting 5 seconds (the defaults are no and 100ms)

From the docs, not run by us
ExecStartPre=/usr/bin/node /srv/api/migrate.js

Run a command first; if it fails the unit fails unless prefixed with -

From the docs, not run by us
[Install] WantedBy=multi-user.target

What systemctl enable hooks the unit into at boot

From the docs, not run by us

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:00

Run every day at 03:00 local time

Try it: crontab-translatorFrom the docs, not run by us
OnCalendar=Mon..Fri 09:00

Run at 09:00 on weekdays; missing seconds default to 00

From the docs, not run by us
OnCalendar=*:0/15

Run every 15 minutes, starting on the hour

From the docs, not run by us
OnCalendar=weekly

Shorthand for Monday 00:00:00; also minutely, hourly, daily, monthly, yearly

From the docs, not run by us
OnBootSec=10min OnUnitActiveSec=1h

Run 10 minutes after boot, then an hour after each activation

From the docs, not run by us
Persistent=true

Catch up on a run missed while the machine was off (default false)

From the docs, not run by us
RandomizedDelaySec=15min

Add a random delay of up to 15 minutes so many hosts don't fire at once

From the docs, not run by us
systemd-analyze calendar "Mon..Fri 09:00"

Normalise an expression and show when it fires next

From the docs, not run by us
systemctl list-timers

Show every timer with its last and next run

From the docs, not run by us
journalctl -u app -f

Follow one unit's log live

Try it: Log ParserFrom the docs, not run by us
journalctl -u app -n 100 --no-pager

Print the last 100 entries without opening a pager

From the docs, not run by us
journalctl -b -1 -u app

Show the unit's log from the previous boot

From the docs, not run by us
journalctl --since yesterday --until "2026-11-28 09:00"

Limit output to a time window

From the docs, not run by us
journalctl -p err -b

Show error-level messages and worse from this boot

From the docs, not run by us
journalctl -u app -g timeout

Filter messages with a regex; an all-lowercase pattern ignores case

From the docs, not run by us
journalctl -u app -o json

Print one JSON object per entry for piping into other tools

From the docs, not run by us
sudo journalctl --vacuum-time=2weeks

Delete archived journal files older than two weeks

From the docs, not run by us

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.service and assuming it starts Postgres.

    After= only sets order. Add Wants= or Requires= 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-reload first, or use systemctl edit, which reloads for you.

  • Leaving out Restart= and expecting systemd to bring a crashed service back.

    The default is Restart=no. Set Restart=on-failure and a sensible RestartSec=.

  • Running systemctl disable app and thinking the service has stopped.

    Disable only removes boot links. Use disable --now, or stop as well.

  • Enabling the .service of 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.