Actualiser automated_shutdown/read.md

This commit is contained in:
2026-01-14 17:55:57 +00:00
parent 16c14bbdc2
commit 8a98493a91

View File

@@ -7,23 +7,20 @@ Crée un fichier /etc/systemd/system/eth-monitor.service :
Colle ce contenu : Colle ce contenu :
<code>
[Unit] [Unit]
Description=Ethernet Connection Monitor Description=Ethernet Connection Monitor
After=network.target After=network.target
</code>
<code>
[Service] [Service]
Type=simple Type=simple
ExecStart=/usr/local/bin/check_eth_connection.sh ExecStart=/usr/local/bin/check_eth_connection.sh
Restart=on-failure Restart=on-failure
RestartSec=60 RestartSec=60
TimeoutStopSec=5 TimeoutStopSec=5
</code>
<code>
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
</code>
c. Créer le timer systemd pour déclencher lextinction c. Créer le timer systemd pour déclencher lextinction
Crée un fichier /etc/systemd/system/eth-monitor.timer : Crée un fichier /etc/systemd/system/eth-monitor.timer :
@@ -32,7 +29,7 @@ Crée un fichier /etc/systemd/system/eth-monitor.timer :
Colle ce contenu : Colle ce contenu :
<code>[Unit] [Unit]
Description=Timer for Ethernet Connection Monitor Description=Timer for Ethernet Connection Monitor
[Timer] [Timer]
@@ -41,7 +38,7 @@ OnUnitActiveSec=1min
AccuracySec=1s AccuracySec=1s
[Install] [Install]
WantedBy=timers.target</code> WantedBy=timers.target
d. Créer un service pour éteindre après 5 minutes de panne d. Créer un service pour éteindre après 5 minutes de panne
@@ -51,7 +48,7 @@ Crée un fichier /etc/systemd/system/shutdown-on-eth-fail.service :
Colle ce contenu : Colle ce contenu :
<code>[Unit] [Unit]
Description=Shutdown on Ethernet Failure Description=Shutdown on Ethernet Failure
After=eth-monitor.service After=eth-monitor.service
@@ -60,7 +57,7 @@ Type=oneshot
ExecStart=/bin/sh -c 'if [ $(journalctl -u eth-monitor.service --since "5 minutes ago" | grep -c "is down") -ge 5 ]; then /sbin/shutdown -h now; fi' ExecStart=/bin/sh -c 'if [ $(journalctl -u eth-monitor.service --since "5 minutes ago" | grep -c "is down") -ge 5 ]; then /sbin/shutdown -h now; fi'
[Install] [Install]
WantedBy=multi-user.target</code> WantedBy=multi-user.target
e. Activer et démarrer les services e. Activer et démarrer les services