Systemd units¶
Service units¶
Start service manually:
User units:
List units¶
List all failed user services:
Instance units from template files¶
Service dependencies¶
To see the dependency tree of a unit (which units systemd will attempt to activate when starting the unit):
This will show the dependent units, with target units recursively expanded. To expand all dependent units recursively, pass the --all flag:
To show the reverse dependency, i.e. which service depends on NetworkManager-wait-online.service:
Service watchdog¶
https://www.medo64.com/2019/01/systemd-watchdog-for-any-service
Timers¶
cd ~/.config/systemd/user
vi test.timer
vi test.service
systemctl --user enable test.timer
systemctl --user start test.timer
systemctl --user list-timers
Changing user timers/services¶
Time formats¶
Unit overrides/drop-ins¶
Show all overrides system-wide:
Show concatenated unit propoerties:
Add override/drop-in¶
Using systemctl edit¶
Use systemctl edit to automatically create a drop-in file:
Then add i.e.
This will create /etc/systemd/system/libvirtd.service.d/override.conf)
with the same content, and reloads the systemd daemon to activate the changes.
Manually¶
Using the example of https://github.com/prometheus-community/node-exporter-textfile-collector-scripts/issues/97#issuecomment-851957644
cd /etc/systemd/system
mkdir prometheus-node-exporter-smartmon.service.d
echo -e '[Service]\nEnvironment=LC_NUMERIC=C' > prometheus-node-exporter-smartmon.service.d/lc_numeric.conf
systemctl daemon-reload
systemctl status prometheus-node-exporter-smartmon
systemctl restart prometheus-node-exporter-smartmon
Debug failing unit¶
Start service when there's an actual network connection¶
Unfortunatly all targets seems to be very static, I can't figure out how to do this dynamically on a Laptop with ever changing connectivity.
Remove systemd services¶
systemctl stop [servicename]
systemctl disable [servicename]
rm /etc/systemd/system/[servicename]
rm /etc/systemd/system/[servicename] # and symlinks that might be related
rm /usr/lib/systemd/system/[servicename]
rm /usr/lib/systemd/system/[servicename] # and symlinks that might be related
systemctl daemon-reload
systemctl reset-failed
SEE (Service Event Extraction)¶
TUI based tool to lookup logs from services (systemd)