[systemd-devel] Return codes of systemctl (status)

Dave Reisner d at falconindy.com
Thu Aug 16 16:18:57 UTC 2018


On Thu, Aug 16, 2018 at 01:27:12PM +0200, Cecil Westerhof wrote:
> The man page of systemctl says:
>     On success, 0 is returned, a non-zero failure code otherwise.
> 
> When I do a systemctl status on a service that is not running I get a 3.
> What other values can be returned and where do I find those?

I believe exit codes are meant to conform to LSB specs:

http://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/iniscrptact.html

In general, I'd suggest not depending on the specific values, but
instead using a more appropriate verb. For example, if you want to
know that a service is running, is 'systemctl is-active'.

dR


More information about the systemd-devel mailing list