Outils pour utilisateurs

Outils du site


tech:systemd_lancer_un_script_a_l_arret

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
tech:systemd_lancer_un_script_a_l_arret [2025/11/09 18:42] Jean-Baptistetech:systemd_lancer_un_script_a_l_arret [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1
Ligne 1: Ligne 1:
 +<!DOCTYPE markdown>
 +{{tag>Brouillon SystemD}}
 +
 +# Systemd lancer un script à l'arrêt
 +
 +Source : http://unix.stackexchange.com/questions/39226/how-to-run-a-script-with-systemd-right-before-shutdown
 +
 +
 +`/etc/systemd/system/jbshutdown.service`
 +~~~ini
 +[Unit]
 +Description=Exec before shutdown
 +
 +[Service]
 +Type=oneshot
 +RemainAfterExit=true
 +ExecStart=/bin/true
 +ExecStop=/root/bin/shutdown.sh
 +
 +[Install]
 +WantedBy=multi-user.target
 +~~~
 +
 +~~~bash
 +chmod +x /root/bin/shutdown.sh
 +systemctl enable jbshutdown.service
 +systemctl start jbshutdown.service
 +~~~
 +
 +Le lien symbolique suivant sera crée :
 +`/etc/systemd/system/multi-user.target.wants/jbshutdown.service`
 +
  

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki