Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • 3
    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 Commented Jan 25, 2020 at 15:00
  • 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 Commented Feb 10, 2023 at 20:27