Skip to main content

Systemd

Get units that failed to start

systemctl list-units --state=failed

Journalctl

journalctl can be used to browse all systemd journal logs.

Useful options

OptionDescription
_EXE=/usr/bin/dockerDisplay logs for a specific executable.
_PID=5000Display logs for a specific process ID.
_UID=1000Show logs for a specific user ID.
-bDisplay logs starting from the current boot.
-b -1Show logs starting from the previous boot.
-fFollow logs in real-time (similar to tail -f).
--grep "pattern"Filter logs by a specific pattern or string.
-kShow kernel logs only.
--no-pageDisable output pagination.
-o json-prettyDisplay logs in JSON format.
-p errFilter logs by priority (e.g. err, warning, info, debug).
-rDisplay logs in reverse order (newest entries first).
--since today --until nowDisplay logs for a specific time range. Each endpoint is optional.
-u nginx.serviceShow logs for a specific service.

Sample unit file insync.service (app auto start)

[Unit]
Description=Insync client

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/bin/sleep 10
ExecStart=/usr/bin/insync start
RestartSec=3

[Install]
WantedBy=default.target

Place the file in /home/$USER/.config/systemd/user

Then run

systemctl --user enable insync

or

sudo systemctl enable insync

to start it for all users.