Create a unit file in /etc/systemd/system
named foo.service.
Then:
sudo systemctl start foo
If the file is modified:
sudo systemctl daemon-reload
sudo systemctl restart foo
systemctl status foo
To list the status of a group of service in a compact form:
systemctl --user list-units foo\*.service
To watch that status live, with an update every second (-n 1
):
watch -n 1 systemctl --user list-units foo\*.service
Stop the service, disable it (in case you enabled it), remove the unit file, reload the daemon and reset failed services:
systemctl stop foo
systemctl disable foo
rm /etc/systemd/system/foo.service
systemctl daemon-reload
systemctl reset-failed
Check the logs:
journalctl -u foo
Erase the logs:
Only the logs (no timestamp or other info)
journalctl --output cat -u foo.service
sudo systemctl enable foo
Use a target: https://www.freedesktop.org/software/systemd/man/latest/systemd.target.html To investigate: https://unix.stackexchange.com/a/516323
https://sekor.eu.org/techlog/systemd-without-root-instances/
Create the unit files in ~/.config/systemd/user/
.
Then use systemctl --user
as you sytemctl command.