Difference between revisions of "Systemd"
Jump to navigation
Jump to search
(Created page with "Replaces initd. It should be more efficient. Honestly I don't see the benefits. The service command invoke script in /etc/init.d. ;service --status-all :Run all scripts with...") |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | [[category:Linux/Unix]] | ||
+ | |||
Replaces initd. It should be more efficient. Honestly I don't see the benefits. | Replaces initd. It should be more efficient. Honestly I don't see the benefits. | ||
− | The service command | + | It also provides timed execution like cron does equally well. |
+ | |||
+ | The service command invokes a script in /etc/init.d. | ||
;service --status-all | ;service --status-all | ||
:Run all scripts with the 'status' option. Tells you which services are up. | :Run all scripts with the 'status' option. Tells you which services are up. | ||
− | + | ;service <service> | |
− | + | :Show all options for service, usually 'start|stop|restart|reload|status' | |
− | + | ;service <service> status | |
+ | :Show detailed status for <service> | ||
+ | ;systemctl enable <service> | ||
+ | :Make the service start at boot-time | ||
+ | ;systemctl list-units | ||
+ | :Show all known units. Alternative for <code>service --status-all</code> that does not work on modern RedHat versions. | ||
;systemctl list-timers | ;systemctl list-timers | ||
:Show all active timers | :Show all active timers | ||
Line 46: | Line 55: | ||
;systemctl daemon-reload | ;systemctl daemon-reload | ||
:After changing a configuration file reload it | :After changing a configuration file reload it | ||
+ | ;systemctl mask <UNIT> | ||
+ | :Link the timer to /dev/null effectively disabling it | ||
+ | |||
+ | ;systemd-analyze [blame|critical-chain] | ||
+ | :Utility that shows what is holding up the boot process |
Latest revision as of 22:01, 4 January 2023
Replaces initd. It should be more efficient. Honestly I don't see the benefits.
It also provides timed execution like cron does equally well.
The service command invokes a script in /etc/init.d.
- service --status-all
- Run all scripts with the 'status' option. Tells you which services are up.
- service <service>
- Show all options for service, usually 'start|stop|restart|reload|status'
- service <service> status
- Show detailed status for <service>
- systemctl enable <service>
- Make the service start at boot-time
- systemctl list-units
- Show all known units. Alternative for
service --status-all
that does not work on modern RedHat versions. - systemctl list-timers
- Show all active timers
E.g for certbot (letsencrypt)
$ systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
do 2018-11-29 00:00:00 CET 2h 5min left wo 2018-11-28 12:00:01 CET 9h ago certbot.timer certbot.service
2 timers listed.
Pass --all to see loaded but inactive timers, too.
$ cat /lib/systemd/system/certbot.timer
[Unit]
Description=Run certbot twice daily
[Timer]
OnCalendar=*-*-* 00,12:00:00
Persistent=true
[Install]
WantedBy=timers.target
$ cat /lib/systemd/system/certbot.service
[Unit]
Description=Certbot
Documentation=file:///usr/share/doc/python-certbot-doc/html/index.html
Documentation=https://letsencrypt.readthedocs.io/en/latest/
[Service]
Type=oneshot
ExecStartPre=/usr/bin/perl -e 'sleep int(rand(3600))'
ExecStart=/usr/bin/certbot -q renew
PrivateTmp=true
- systemctl daemon-reload
- After changing a configuration file reload it
- systemctl mask <UNIT>
- Link the timer to /dev/null effectively disabling it
- systemd-analyze [blame|critical-chain]
- Utility that shows what is holding up the boot process