Systemd usage: Difference between revisions
From wikinotes
No edit summary |
No edit summary |
||
(12 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Instructions on viewing, configuring, monitoring your system's services/timers/targets. | |||
systemctl | = Documentation = | ||
<blockquote> | |||
{| class="wikitable" | |||
|- | |||
| <code>man systemctl</code> || https://man.archlinux.org/man/core/systemd/systemctl.1.en | |||
|- | |||
|} | |||
</blockquote><!-- Documentation --> | |||
= Service Management = | |||
<blockquote> | |||
Manage Service | |||
<syntaxhighlight lang="bash"> | |||
systemctl {enable,start,stop,restart} myservice | |||
</syntaxhighlight> | |||
Override Service Options | |||
<syntaxhighlight lang="bash"> | |||
# creates /etc/systemd/system/myservice.service.d/override.conf | |||
</ | # where you can override service settings | ||
systemctl edit myservice.service | |||
</syntaxhighlight> | |||
Info about services/status | |||
<syntaxhighlight lang="bash"> | |||
systemctl {is-active,is-enabled} myservice | |||
systemctl show \ | |||
[-p property,...] `# list specific properties` \ | |||
[foo.service] `# filter to unitfile` \ | |||
</syntaxhighlight> | |||
</blockquote><!-- Service Management --> | |||
= System Management = | |||
<blockquote> | |||
<syntaxhighlight lang="bash"> | |||
systemctl --system daemon-reload # reload unitfiles | |||
systemctl [--user] list-units -t target # list all targets | |||
# list filepaths for each service | |||
for service in $(systemctl list-units -t service,timer | head -n -6 | sed -n '2,$p' | sed -E 's/^[^a-zA-Z0-9]+//' | awk -F' ' '{ print $1 }'); do | |||
systemctl show -P Id,FragmentPath "$service" | sed 'N;s/\n/ /' | |||
done | column -t | |||
</syntaxhighlight> | |||
systemctl {list-units,list-timers,list-sockets} | |||
</blockquote><!-- Management --> | |||
= Logs = | |||
<blockquote> | |||
See [[systemd journald]] | |||
</blockquote><!-- Logs --> |
Latest revision as of 17:36, 11 December 2022
Instructions on viewing, configuring, monitoring your system's services/timers/targets.
Documentation
man systemctl
https://man.archlinux.org/man/core/systemd/systemctl.1.en
Service Management
Manage Service
systemctl {enable,start,stop,restart} myserviceOverride Service Options
# creates /etc/systemd/system/myservice.service.d/override.conf # where you can override service settings systemctl edit myservice.serviceInfo about services/status
systemctl {is-active,is-enabled} myservice systemctl show \ [-p property,...] `# list specific properties` \ [foo.service] `# filter to unitfile` \
System Management
systemctl --system daemon-reload # reload unitfiles systemctl [--user] list-units -t target # list all targets # list filepaths for each service for service in $(systemctl list-units -t service,timer | head -n -6 | sed -n '2,$p' | sed -E 's/^[^a-zA-Z0-9]+//' | awk -F' ' '{ print $1 }'); do systemctl show -P Id,FragmentPath "$service" | sed 'N;s/\n/ /' done | column -tsystemctl {list-units,list-timers,list-sockets}
Logs
See systemd journald