Systemd services commands
mouse 378 · person cloud · link
Last update
2018-09-12
2018
09-12
« — »
1
2
3
4
5
6
7
8
9
10
11
12
13
systemctl # list running services

# basic service management
systemctl start      foo.service
systemctl stop       foo.service
systemctl restart    foo.service
systemctl status     foo.service

# manage start on boot
systemctl enable     foo.service
systemctl disable    foo.service
systemctl is-enabled foo.service
systemctl list-unit-files # see all enabled/disable units

Debug and logs:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
journalctl # inspect all logs
journalctl -b-1 -e # inspect last boot logs

cat /var/log/boot.log

# boot graphs:
apt-get install graphviz
systemd-analyze plot > boot-chart.svg
systemd-analyze           dot | dot -Tsvg > boot-full.svg
systemd-analyze --order   dot | dot -Tsvg > boot-order.svg
systemd-analyze --require dot | dot -Tsvg > boot-require.svg

systemctl list-dependencies
systemd-analyze critical-chain

Add a new unit (see docs):

1
2
3
4
ln -f /opt/systemd-units/name.service /lib/systemd/system/
systemctl enable name.service

systemctl daemon-reload # reload all modified units

Note: Do NOT use symlinks otherwise systemd won't enable them.


Source: Dynacont