Timeline for The "proper" way to test if a service is running in a script
Current License: CC BY-SA 4.0
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 10, 2023 at 20:27 | comment | added | Paul Stoner | For those visiting from the future (As I am), or from another planetary system in the universe. Version 0.67.6 and higher of the Microsoft Store version of WSL now supports SystemD See this blog post | |
| Jan 25, 2020 at 15:00 | comment | added | Nathan | systemctl seems better in general, but in Windows Subsystem for Linux (v1), that won't work. +1 for this, which works well enough for me in WSL. If you don't want to use $?, you could also put, e.g., pidof cron in the test directly or do cron_pid=$(pidof cron) and use it later. The output is an empty string if the service isn't running, so one can test for it like if [ -z $cron_pid ]; then dosomething; fi | |
| Nov 13, 2019 at 1:39 | review | Late answers | |||
| Nov 13, 2019 at 2:05 | |||||
| Nov 13, 2019 at 1:25 | review | First posts | |||
| Nov 13, 2019 at 6:10 | |||||
| Nov 13, 2019 at 1:23 | history | answered | Tuhin Paul | CC BY-SA 4.0 |