[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: No feedback from systemd / "systemctl stop X"... Nothing on stdout, nothing that `echo $?` can see...



On 12 March 2015 at 01:13, Don Armstrong <don@debian.org> wrote:
> On Wed, 11 Mar 2015, The Wanderer wrote:
>> Running those commands doesn't give you output from 'systemctl stop
>> foo' or the like, however.
>
>> I thought the OP was asking how to determine, from the exit code
>> and/or the console output of 'systemctl stop foo' (or a similar
>> command, one that actually _alters_ the status of a service), whether
>> the command actually succeeded.
>
> If you want to know that, then do something like:
>
> systemctl start foo && systemctl is-active foo;
>
> or
>
> systemctl stop foo && ! systemctl is-active foo && ! systemctl is-failed \
> foo;
>
> Presumably you could even write a shell function to do this if that's
> something that you actually wanted.
>
>> You can certainly run these commands afterwards, and get the status of
>> the service that way, but that's no substitute for being able to get
>> output or the like directly from the original control command.
>>
>> Does systemd really not provide any "verbose" mode for its
>> service-control commands, in which they report what they are doing?
>
> No. Really, all systemctl start/stop do is tell systemd to actually stop
> or start the service, and optionally block until the action is
> completed.
>
> I suppose someone could make an argument that including a verbose flag
> or something might be useful, but considering that you can achieve
> similar functionality with existing discrete tools, I'm not sure that
> growing additional code and documentation to support such an option is
> worth it.
>
> Look at the definition of start_unit in
> http://cgit.freedesktop.org/systemd/systemd/tree/src/systemctl/systemctl.c
> for the current code.
>
>
> --
> Don Armstrong                      http://www.donarmstrong.com

Now we're talking!

jessie-1:~# systemctl stop cups
Warning: Stopping cups.service, but it can still be activated by:
  cups.path
  cups.socket

jessie-1:~# systemctl is-active cups
inactive
jessie-1:~# echo $?
3

jessie-1:~# systemctl start cups
jessie-1:~# systemctl is-active cups
active
jessie-1:~# echo $?
0

That's it!

By not "polluting" the Linux boot with "starting this [OK]", "starting
that [OK]".... The Debian boot is now more "clear" with systemd, then,
if I need a feedback, I can ask for it...

Thanks Don!

Best,
Thiago


Reply to: