[systemd-devel] systemctl is-active command returns inactive even if the unit does not exist

Michael Chapman mike at very.puzzling.org
Thu Jan 25 07:06:46 UTC 2018


On Thu, 25 Jan 2018, Kevin Hsu wrote:
> Hi folks,
>
> "systemctl is-active" command gives "inactive" no matter the unit exists
> and indeed inactive or it just not exist. This behavior is semantically
> true since a unit can never be active
> if it does not exist. But "systemctl is-enabled" command will give a clear
> result "Failed to get unit file state for no-exist.service: No such file or
> directory" to indicate user the existence
> of the given unit. I am wondering if "systemctl is-active" should behave
> the same.

I don't think it would be possible to change what "systemctl is-active" 
prints out now, and I think it makes sense for it to track the ActiveState 
property of the unit precisely.

You can get the properties of a unit using "systemctl show". For example:

   $ systemctl show --property LoadState,ActiveState,SubState \
         does-not-exist.service
   LoadState=not-found
   ActiveState=inactive
   SubState=dead

As you can see here, what you're interested in is the "load state" of the 
unit, which is somewhat orthogonal to the unit's "active state".


More information about the systemd-devel mailing list