Outils pour utilisateurs

Outils du site


informatique:system_admin:systemd

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
informatique:system_admin:systemd [31/10/2025 12:15] – [systemd] cyrilleinformatique:system_admin:systemd [01/12/2025 10:15] (Version actuelle) – [Resolve] cyrille
Ligne 2: Ligne 2:
  
 Voir aussi [[/informatique/system_admin/journalctl|journalctl]] Voir aussi [[/informatique/system_admin/journalctl|journalctl]]
 +
 +  * https://systemd.io/
 +  * https://www.freedesktop.org/software/systemd/man/latest/
  
 Les directives: Les directives:
Ligne 9: Ligne 12:
   * https://www.freedesktop.org/software/systemd/man/latest/systemd-analyze.html   * https://www.freedesktop.org/software/systemd/man/latest/systemd-analyze.html
  
-Pour envoyer une notification en cas d'échec, créer un ''template service'' :+Pour envoyer une notification en cas d'échec d'exécution, créer un ''template service'' :
   * https://www.baeldung.com/linux/systemd-service-fail-notification   * https://www.baeldung.com/linux/systemd-service-fail-notification
   * https://superuser.com/questions/1621517/having-all-systemd-timers-mail-to-root-on-error   * https://superuser.com/questions/1621517/having-all-systemd-timers-mail-to-root-on-error
 +
 +''OnFailure'' est lié au démarrage du service. Pour traiter un retour d'erreur il faut créer un traitement dans ''ExecStopPost''.
  
 ===== Timer (Cron) ===== ===== Timer (Cron) =====
Ligne 22: Ligne 27:
 - https://blog.stephane-robert.info/docs/admin-serveurs/linux/timers/ - https://blog.stephane-robert.info/docs/admin-serveurs/linux/timers/
 - https://www.siberoloji.com/how-to-use-systemd-timers-instead-of-cron-in-debian-12-bookworm/ - https://www.siberoloji.com/how-to-use-systemd-timers-instead-of-cron-in-debian-12-bookworm/
 +
 +==== Exemple ====
 +
 +les stats de livraison d'emails avec Postfix sur handipause.fr :
 +
 +Le service ''/etc/systemd/system/mail-stats.service''
 +
 +<code>
 +#
 +# Génère des stats de delivery pour Postfix
 +#
 +# Doc:
 +# Timer: https://blog.stephane-robert.info/docs/admin-serveurs/linux/timers/
 +# Service: https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html
 +# Unit: https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html
 +#
 +[Unit]
 +Description=Génère qlqs stats Postfix
 +# A space-separated list of one or more units that are activated when this unit enters the "failed" state.
 +OnFailure=onfailure-email@%N.service
 +
 +[Service]
 +Type=oneshot
 +ExecStart=/usr/bin/php /home/debian/postfix-delivery-status/scripts/deliveryStats/deliveryStats.php /home/debian/postfix-delivery-status/conf/handipause.conf.php /var/www/html
 +# Additional commands that are executed after the service is stopped.
 +#ExecStopPost=
 +</code>
 +
 +Le timer ''/etc/systemd/system/mail-stats.timer''
 +
 +<code>
 +[Unit]
 +Description=Génère périodiquement qlqs stats Postfix
 +
 +[Timer]
 +# https://www.freedesktop.org/software/systemd/man/latest/systemd.time.html#
 +# check format with `systemd-analyze calendar "*-*-* 00/2:00:00"`
 +OnCalendar=*-*-* 00/6:00:00
 +Persistent=true
 +
 +[Install]
 +WantedBy=timers.target
 +</code>
 +
 +===== Resolve =====
 +
 +La gestion DSN par systemd.
 +
 +  * [[https://www.malekal.com/configurer-cache-dns-linux-systemd-resolved-dnsmasq-bind/|Configurer un cache DNS sur Linux avec systemd-resolved, dnsmasq ou BIND]]
 +  * https://www.freedesktop.org/wiki/Software/systemd/writing-network-configuration-managers/
 +
 +<code bash>
 +sudo systemctl status systemd-resolved.service
 +
 +# ==========
 +
 +$ sudo resolvectl status
 +Global
 +       Protocols: +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
 +resolv.conf mode: uplink
 +
 +Link 2 (ens3)
 +    Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
 +         Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
 +Current DNS Server: 2001:41d0:3:163::1
 +       DNS Servers: 2001:41d0:3:163::1 213.186.33.99
 +
 +Link 3 (ens4)
 +    Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
 +         Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
 +Current DNS Server: 213.186.33.99
 +       DNS Servers: 213.186.33.99
 +
 +# ==========
 +
 +$ sudo resolvectl statistics
 +DNSSEC supported by current servers: no
 +
 +Transactions              
 +Current Transactions: 0
 +  Total Transactions: 2906
 +                          
 +Cache                     
 +  Current Cache Size: 1
 +          Cache Hits: 478
 +        Cache Misses: 4417
 +                          
 +DNSSEC Verdicts           
 +              Secure: 0
 +            Insecure: 0
 +               Bogus: 0
 +       Indeterminate: 0
 +
 +# ==========
 +
 +$ sudo resolvectl query 1.1.1.1
 +1.1.1.1: one.one.one.one                       -- link: ens3
 +-- Information acquired via protocol DNS in 23.6ms.
 +-- Data is authenticated: no; Data was acquired via local or encrypted transport: no
 +-- Data from: network
 +
 +</code>
 +
  
informatique/system_admin/systemd.1761909339.txt.gz · Dernière modification : de cyrille

Sauf mention contraire, le contenu de ce wiki est placé sous les termes de la licence suivante : CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki