Systemd
From BCCD 3.0
(Difference between revisions)
(→Path cheat sheet) |
|||
Line 5: | Line 5: | ||
** <code>system</code> - start once per boot | ** <code>system</code> - start once per boot | ||
* Place <b>per-user</b> custmo units <code>~/.config/systemd/user</code> | * Place <b>per-user</b> custmo units <code>~/.config/systemd/user</code> | ||
- | ** Use <code><b> | + | ** Use <code><b>systemctl</b> --user</code> to manipulate |
= Command cheat sheet = | = Command cheat sheet = | ||
Line 21: | Line 21: | ||
* Edit service, using EDITOR: <code>systemctl edit --full <i>service-name></i></code> | * Edit service, using EDITOR: <code>systemctl edit --full <i>service-name></i></code> | ||
* Get unit output: <code>journalctl -u <i>unit-name</i></code> | * Get unit output: <code>journalctl -u <i>unit-name</i></code> | ||
+ | * Get timer status: <code>systemctl list-timers</code> | ||
= Example unit = | = Example unit = |
Revision as of 23:41, 11 October 2020
Contents |
Path cheat sheet
- Place global custom units in
/etc/systemd
:-
user
- start once per login -
system
- start once per boot
-
- Place per-user custmo units
~/.config/systemd/user
- Use
systemctl --user
to manipulate
- Use
Command cheat sheet
- Print blocking portions of the boot tree:
systemd-analyze critical-chain
- Print all managed objects:
systemctl -a
- Print failed objects:
systemctl --failed
- Print jobs:
systemctl list-jobs
- Print all services:
systemctl list-units -t service --all
- Print all targets:
systemctl list-units -t target
- Print default target:
systemctl get-default
- Print default target:
- Print service config:
systemctl show [ service-name ]
- Print service status:
systemctl status [ service-name ]
- Enable service, making symlinks:
systemctl enable /etc/systemd/user/bccd-passwd-wrapper.service
- Edit service, using EDITOR:
systemctl edit --full service-name>
- Get unit output:
journalctl -u unit-name
- Get timer status:
systemctl list-timers
Example unit
[Unit] Description="Set BCCD user password" [Service] ExecStart=/bin/bccd-passwd-wrapper bccd Type=oneshot # This service is expected to exit completely even if it is successful RemainAfterExit=yes # Do not restart after everything exits Restart=no # This service requires user interaction via the TTY StandardInput=tty StandardOutput=tty [Install] WantedBy=multi-user.target
Troubleshooting
Boot problems
From FreeDesktop's debugging guide
- Add to the kernel boot line:
systemd.log_level=debug systemd.log_target=console
Disabling SysV init redirection
Systemd will generate a wrapper around SysV-style init script, which can make debugging trickier. To disable, set the environment variable _SYSTEMCTL_SKIP_REDIRECT=1
.
See https://www.turnkeylinux.org/blog/debugging-systemd-sysv-init-compat for more details