Scripting - testing if a service is up

In a shell script, how can I test if a service is up and running? Is there a quick way? Or just use pgrep?

Not sure what you are looking for but the systemctl status {service-name} is the built in tool for checking services.

1 Like
systemctl is-active $servicename

will probably do what you need.


Yes, but it is not good for scripting. @Beardedgeek72 :smiley:

Fantastic, I am having problems with greenclip on openbox, so:

systemctl is-active --user greenclip

Does it.

:edit: read what you paste you numpty (me!).