f405994fd1935780f0c14eb81850e3360feb003a
technology/linux/general/systemctl.md
... | ... | @@ -1,5 +1,7 @@ |
1 | 1 | # systemctl |
2 | 2 | |
3 | +also see [journalctl](journalctl) |
|
4 | + |
|
3 | 5 | ```bash |
4 | 6 | systemctl list-units [ --all | --type=service ] |
5 | 7 | ``` |
... | ... | @@ -9,13 +11,38 @@ systemctl list-units [ --all | --type=service ] |
9 | 11 | systemctl list-unit-files |
10 | 12 | ``` |
11 | 13 | |
12 | -## create service file |
|
14 | +#### create service file |
|
13 | 15 | ``` |
14 | 16 | vi /etc/systemd/system/<name>.service |
15 | 17 | ``` |
16 | 18 | |
17 | -[journalctl](journalctl) |
|
19 | +([manage systemd][]) |
|
20 | + |
|
21 | +## user services |
|
22 | +run `systemctl` (without sudo) and with the `--user` option |
|
23 | + |
|
24 | +service files are created under '$HOME/.config/systemd/user' |
|
25 | + |
|
26 | +### example user service file |
|
27 | +``` |
|
28 | +[Unit] |
|
29 | +Description=This is an example |
|
30 | + |
|
31 | +[Service] |
|
32 | +ExecStart=/path/to/command |
|
33 | + |
|
34 | +[Install] |
|
35 | +WantedBy=default.target |
|
36 | +``` |
|
37 | +([writing user units][]) |
|
38 | + |
|
39 | +enable and start the user service (without sudo) |
|
40 | +``` |
|
41 | +systemctl --user enable <service> |
|
42 | +systemctl --user start <service> |
|
43 | +systemctl --user status <service> |
|
44 | +``` |
|
45 | + |
|
18 | 46 | |
19 | -## ref |
|
20 | -- :1: https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units |
|
21 | -- https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units |
|
47 | +[manage systemd]: https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units |
|
48 | +[writing user units]: https://wiki.archlinux.org/index.php/Systemd/User#Writing_user_units |