Outils pour utilisateurs

Outils du site


Panneau latéral

linux:systemd (lu 1171 fois)

Table des matières

SystemD

Une belle doc en français ⇒ https://lea-linux.org/documentations/systemd

Lire les log

— source: https://www.linuxtricks.fr/wiki/utiliser-journalctl-les-logs-de-systemd

journalctl

comme tail -f

journalctl -f

Filtrer par service

journalctl -u crond

Timer

Lister les timers

systemctl list-timers --all

Exemple d’un timer

certbot.timer will execute the certbot.service at 12 am and 12 pm.

# cat /lib/systemd/system/certbot.timer
[Unit]
Description=Run certbot twice daily
 
[Timer]
OnCalendar=*-*-* 00,12:00:00
RandomizedDelaySec=3600
Persistent=true
 
[Install]
WantedBy=timers.target

Script venant de l’install par centos

[Unit]
Description=This is the timer to set the schedule for automated renewals
 
[Timer]
OnCalendar=daily
RandomizedDelaySec=6hours
Persistent=true
 
[Install]
WantedBy=timers.target

and certbot.service will execute the renew command.

# 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
ExecStart=/usr/bin/certbot -q renew
PrivateTmp=true

Script venant de l’install par centos

[Unit]
Description=This service automatically renews any certbot certificates found
 
[Service]
EnvironmentFile=/etc/sysconfig/certbot
Type=oneshot
ExecStart=/usr/bin/certbot renew $PRE_HOOK $POST_HOOK $RENEW_HOOK $CERTBOT_ARGS

Surtout de pas oublier d’activer ce timer

systemctl enable certbot-renew.timer
systemctl start certbot-renew.timer
systemctl status certbot-renew.timer
linux/systemd.txt · Dernière modification: 07-10-2019 10:06 de edmc73