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
Option | Description |
---|---|
_EXE=/usr/bin/docker | Display logs for a specific executable. |
_PID=5000 | Display logs for a specific process ID. |
_UID=1000 | Show logs for a specific user ID. |
-b | Display logs starting from the current boot. |
-b -1 | Show logs starting from the previous boot. |
-f | Follow logs in real-time (similar to tail -f ). |
--grep "pattern" | Filter logs by a specific pattern or string. |
-k | Show kernel logs only. |
--no-page | Disable output pagination. |
-o json-pretty | Display logs in JSON format. |
-p err | Filter logs by priority (e.g. err , warning , info , debug ). |
-r | Display logs in reverse order (newest entries first). |
--since today --until now | Display logs for a specific time range. Each endpoint is optional. |
-u nginx.service | Show 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.