Timeline for The "proper" way to test if a service is running in a script
Current License: CC BY-SA 4.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 27, 2020 at 1:46 | comment | added | Manngo | I put this into a cron job, and added logging: systemctl is-active --quiet <service name> || (echo '…' >> log.txt && systemctl restart <service name>). | |
| Jan 21, 2020 at 10:35 | comment | added | Steen Schütt | I think Phil's point is that using is-active means that the script will restart the service even if it was stopped manually, which could cause some confusion. | |
| Sep 8, 2019 at 2:02 | comment | added | asterisk | yes, but for me.. i wanted to practice myself and assume everything is running when it is not. so i can go things verify other stuffs with it. simply if you just want to check if it's not running, then 'is-failed' is a rightful choice. :) | |
| Sep 6, 2019 at 16:14 | comment | added | Phill Healey | You could also use `is-failed´ to test if a restart is needed. It seems a bit more intuitive for restarting a failed service. | |
| Feb 13, 2019 at 8:05 | review | Late answers | |||
| Feb 13, 2019 at 8:14 | |||||
| Feb 13, 2019 at 7:50 | review | First posts | |||
| Feb 13, 2019 at 7:57 | |||||
| Feb 13, 2019 at 7:47 | history | answered | asterisk | CC BY-SA 4.0 |