SynologyRS
Administration

systemd services: reading logs and fixing what broke

📅 2024-12-19✎ 6 min read

journalctl patterns that save hours, and how to read a failed unit.

Almost every “why did my service die” question answers itself in journalctl if you ask the right two commands. The trick is knowing which flags, and reading the exit status instead of the last line.

The two commands I reach for

systemctl --failed --no-pager --full
journalctl -u myservice --since "-2h" --no-pager

Read the exit code

“Failed with result ‘exit-code’” is useless until you pair it with the exit code and the surrounding log lines. exit 1 means something different than exit 203/EXEC — the latter usually means the executable path or permissions are wrong.

Reproduce it

sudo -u www-data /usr/local/bin/myapp --config /etc/myapp/config.yaml

Running the exec line by hand almost always shows the real error faster than any log parser. It also reveals environment differences — a service runs as its own user with its own PATH, which is why it works by hand and fails under systemd.

A few units I keep handy

systemctl status myservice --no-pager
systemctl reset-failed myservice
systemctl edit myservice   # drop-in override