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 :
<code>
[Unit]
Description=Ethernet Connection Monitor
After=network.target
</code>
<code>
[Service]
Type=simple
ExecStart=/usr/local/bin/check_eth_connection.sh
Restart=on-failure
RestartSec=60
TimeoutStopSec=5
</code>
<code>
[Install]
WantedBy=multi-user.target
</code>
c. Créer le timer systemd pour déclencher lextinction
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 :
<code>[Unit]
[Unit]
Description=Timer for Ethernet Connection Monitor
[Timer]
@@ -41,7 +38,7 @@ OnUnitActiveSec=1min
AccuracySec=1s
[Install]
WantedBy=timers.target</code>
WantedBy=timers.target
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 :
<code>[Unit]
[Unit]
Description=Shutdown on Ethernet Failure
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'
[Install]
WantedBy=multi-user.target</code>
WantedBy=multi-user.target
e. Activer et démarrer les services