systemd ignores / overrides 'shutdown -t' delay?

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

systemd ignores / overrides 'shutdown -t' delay?

The Wanderer
I've recently built a VM against jessie, and just for the heck of it, I
left it with the default systemd-based configuration.

When I log in to the console as root and try to shut down, I get the
following:

========
# shutdown -h -t 0
Broadcast message from root@hostname (Fri 2015-09-11 14:08:29 EDT):

The system is going down for power off at Fri 2015-09-11 14:09:29 EDT!
========

I.e., even though I specified a shutdown delay of zero seconds (meaning
to shut down immediately), the shutdown is being delayed by 60 seconds.

What I expected instead was a response including the line

========
The system is going down for power off NOW!
========

and an immediate shutdown (without even enough delay to log root out via
Ctrl-D), which is what I get on my other systems, where systemd is not
the active init system.

Google has not been helpful in trying to figure out why this might be
happening; there are plenty of hits explaining how to make systemd
inhibit shutdown or add a delay or the like, and a few hits related to
Debian bug 635777 (which seems to be about a delay after the shutdown
has actually begun, not about a delay in initiating the shutdown), but
no real useful hints.

Grepping recursively and case-insensitively through /etc/systemd for
'shut' and '60' (separately) produces only two hits, neither of which
seems relevant.

Any idea why this is happening, and how to get this VM to respect the
semantics of the shutdown command again?

--
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw


signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: systemd ignores / overrides 'shutdown -t' delay?

recoverym4n
 Hi.

On Fri, 11 Sep 2015 14:22:12 -0400
The Wanderer <[hidden email]> wrote:

> I've recently built a VM against jessie, and just for the heck of it, I
> left it with the default systemd-based configuration.
>
> When I log in to the console as root and try to shut down, I get the
> following:
>
> ========
> # shutdown -h -t 0
> Broadcast message from root@hostname (Fri 2015-09-11 14:08:29 EDT):
>
> The system is going down for power off at Fri 2015-09-11 14:09:29 EDT!
> ========
>
> I.e., even though I specified a shutdown delay of zero seconds (meaning
> to shut down immediately), the shutdown is being delayed by 60 seconds.
>
> What I expected instead was a response including the line
>
> ========
> The system is going down for power off NOW!
> ========
<skip>
> Any idea why this is happening, and how to get this VM to respect the
> semantics of the shutdown command again?

It seems like you're hitting 'undefined behavior' of shutdown.

shutdown(8) says:

The  time argument can have different formats.  First, it can be
an absolute time in the format hh:mm, in which hh is the hour (1 or 2
digits) and mm is the minute of the hour (in two digits).  Second, it
can be in the format +m, in which m is the number of minutes to wait.
The word now is an alias for +0.


So, I'd try to use shutdown the way the man says first.
I.e.

shutdown -h now

Reco

Reply | Threaded
Open this post in threaded view
|

Re: systemd ignores / overrides 'shutdown -t' delay?

Ralph Katz
In reply to this post by The Wanderer
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

On 09/11/2015 02:22 PM, The Wanderer wrote:

> I've recently built a VM against jessie, and just for the heck of
> it, I left it with the default systemd-based configuration.
>
> When I log in to the console as root and try to shut down, I get
> the following:
>
> ======== # shutdown -h -t 0 Broadcast message from root@hostname
> (Fri 2015-09-11 14:08:29 EDT):
>
> The system is going down for power off at Fri 2015-09-11 14:09:29
> EDT! ========
>
> I.e., even though I specified a shutdown delay of zero seconds
> (meaning to shut down immediately), the shutdown is being delayed
> by 60 seconds.
>
> What I expected instead was a response including the line
>
> ======== The system is going down for power off NOW! ========
>
> and an immediate shutdown (without even enough delay to log root
> out via Ctrl-D), which is what I get on my other systems, where
> systemd is not the active init system.
>
> Google has not been helpful in trying to figure out why this might
> be happening; there are plenty of hits explaining how to make
> systemd inhibit shutdown or add a delay or the like, and a few hits
> related to Debian bug 635777 (which seems to be about a delay after
> the shutdown has actually begun, not about a delay in initiating
> the shutdown), but no real useful hints.
>
> Grepping recursively and case-insensitively through /etc/systemd
> for 'shut' and '60' (separately) produces only two hits, neither of
> which seems relevant.
>
> Any idea why this is happening, and how to get this VM to respect
> the semantics of the shutdown command again?
>

There is no "-t" option.

man shutdown
shutdown [OPTIONS...] [TIME] [WALL...]
"If no time argument is specified, "+1" is implied."

Regards,
Ralph




-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Icedove - http://www.enigmail.net/

iQEcBAEBCgAGBQJV8yJIAAoJECe2FpioHXO6NBYIAJ8frLAbVmpbgYg5Ty8u17+t
NYthuajNt2qvF3gwJ0npq7Hw5ZQ9CoDMry4lpeWi5jJ4a5J0eYD7109J/Im5nXC5
A3demPB38tSyjzREJxC86uD+VA5fOIOEP52At3/t0IV7zc2R3kmkwK/SZbCUDL30
wte8JefOiTfRE5BXz0GM9YZaq3iMhSL8gI6jSf9Rf9hT35Aph40tT7FPEY8wXT0W
IDB9hD09zyJjSvuQsUU6IMowpfReIQ5i5OVKs3VdLDIpB7eTG8siYxa7bkSZ2gfl
5Ed8GFTr5u4+X74ch8fQyp/GZ/8EvV8l5wewgZQo1AJ7T7ZYTavTHctFygk8TO4=
=QTKM
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|

Re: systemd ignores / overrides 'shutdown -t' delay?

Don Armstrong
In reply to this post by The Wanderer
On Fri, 11 Sep 2015, The Wanderer wrote:
> and an immediate shutdown (without even enough delay to log root out
> via Ctrl-D), which is what I get on my other systems, where systemd is
> not the active init system.

I suspect that the shutdown process has actually started immediately,
but that one of the daemons that you are running (or a filesystem) is
not being properly unmounted or stopped, and systemd is waiting until it
hits the timeout for a shutdown.

If you look at the output of journalctl -ar -b -1; you should be able to
see what actually happened.

--
Don Armstrong                      http://www.donarmstrong.com

But if, after all, we are on the wrong track, what then? Only
disappointed human hopes, nothing more. And even if we perish, what
will it matter in the endless cycles of eternity?
 -- Fridtjof Nansen _Farthest North_ p152

Reply | Threaded
Open this post in threaded view
|

Re: systemd ignores / overrides 'shutdown -t' delay?

Brian
In reply to this post by The Wanderer
On Fri 11 Sep 2015 at 14:22:12 -0400, The Wanderer wrote:

> I've recently built a VM against jessie, and just for the heck of it, I
> left it with the default systemd-based configuration.
>
> When I log in to the console as root and try to shut down, I get the
> following:
>
> ========
> # shutdown -h -t 0

shutdown(8) doesn't have a "-t" option.

Reply | Threaded
Open this post in threaded view
|

Re: systemd ignores / overrides 'shutdown -t' delay?

David Wright-3
In reply to this post by The Wanderer
Quoting The Wanderer ([hidden email]):

> I've recently built a VM against jessie, and just for the heck of it, I
> left it with the default systemd-based configuration.
>
> When I log in to the console as root and try to shut down, I get the
> following:
>
> ========
> # shutdown -h -t 0
> Broadcast message from root@hostname (Fri 2015-09-11 14:08:29 EDT):
>
> The system is going down for power off at Fri 2015-09-11 14:09:29 EDT!
> ========
>
> I.e., even though I specified a shutdown delay of zero seconds (meaning
> to shut down immediately), the shutdown is being delayed by 60 seconds.
>
> What I expected instead was a response including the line
>
> ========
> The system is going down for power off NOW!
> ========
>
> and an immediate shutdown (without even enough delay to log root out via
> Ctrl-D), which is what I get on my other systems, where systemd is not
> the active init system.

man shutdown

I think the arguments have changed/been juggled/reduced.

The lack of -F is especially annoying.

Cheers,
David.

Reply | Threaded
Open this post in threaded view
|

Re: systemd ignores / overrides 'shutdown -t' delay?

The Wanderer
In reply to this post by Ralph Katz
On 2015-09-11 at 14:49, Ralph Katz wrote:

> On 09/11/2015 02:22 PM, The Wanderer wrote:
>
>> I've recently built a VM against jessie, and just for the heck of
>> it, I left it with the default systemd-based configuration.
>>
>> When I log in to the console as root and try to shut down, I get
>> the following:

>> Any idea why this is happening, and how to get this VM to respect
>> the semantics of the shutdown command again?
>
> There is no "-t" option.
>
> man shutdown
> shutdown [OPTIONS...] [TIME] [WALL...]
> "If no time argument is specified, "+1" is implied."

There is under sysvinit:

man shutdown
/sbin/shutdown [-krhPHfFnc] [-t sec] time [warning message]


Apparently I've been misunderstanding and mis-using shutdown's syntx all
of these years. I've been under the impression that the argument to '-t'
was the time to delay before shutting down, but the man page says that
that delay is specified by the 'time' argument instead.

The confusing part of this is that the man page says that the 'time'
argument is mandatory, but I have been using shutdown for years and
years without passing that argument. I've used the exact syntax I gave
('shutdown -h -t 0'), and it's been accepted and interpreted as if I had
instead typed 'shutdown -h 0'.

At least I probably now know how to shut down this VM without delays.
It's still odd / bothersome that systemd's shutdown would see the
unsupported / unrecognized '-t' option and just proceed blithely along,
rather than erroring out on the presumption that a mistake may have been
made.

--
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw


signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

systemd ignores / overrides 'shutdown -t' delay?

Jonathan de Boyne Pollard
In reply to this post by Ralph Katz
Ralph Katz:

> There is no "-t" option.
>

In fact there is.  It's undocumented; and is one of four undocumented
compatibility options, alongside -a, -f, and -F, that are simply parsed
and then ignored.  There is a fifth undocumented option with an effect, -K.


Reply | Threaded
Open this post in threaded view
|

systemd ignores / overrides 'shutdown -t' delay?

Jonathan de Boyne Pollard
In reply to this post by David Wright-3
David Wright:

> I think the arguments have changed/been juggled/reduced. The lack of
> -F is especially annoying.
>

They haven't been.  All of the documented options to upstart's shutdown
command and the System 5 rc shutdown command are recognized, albeit that
four of them, including -F, are then simply ignored.  What has in fact
happened is twofold:

* The systemd people decided a few years ago that flag files are a bad
way to signal fsck at bootstrap, given that if a filesystem is dirty and
potentially corrupt one probably doesn't want to go around writing flag
files to it.  So the kernel command line is used for that.  It's rather
harder for the shutdown command to rewrite the kernel command line for
the next reboot than it was to create empty flag files.  (Given the
inclusion of a kernel loader in systemd, it's not beyond the bounds of
possibility for the systemd shutdown command to grow an internal
interface to the systemd kernel loader that permits it to write "at next
boot" action settings, of course. But none exists yet.)  So the -f and
-F options do nothing.
* Single-user mode has become "rescue mode", and it's no longer a state
reachable by shutdown in systemd operating systems like Debian.  It's a
startup state, not a shutdown one.  The default for the shutdown command
used to be that without any options it would place the system in
single-user mode mode.  The -h option would explicitly tell it to power
off or halt instead, with the -H or -P options specifying which one, the
choice in their absence being up to the system.  Since single-user mode
is no longer a shutdown option, -h is effectively on by default,
defaulting to halt.

* https://bugzilla.redhat.com/show_bug.cgi?id=806369#c13
* https://bugzilla.redhat.com/show_bug.cgi?id=733874#c2
* http://unix.stackexchange.com/a/196471/5132
* http://unix.stackexchange.com/a/196014/5132

Reply | Threaded
Open this post in threaded view
|

systemd ignores / overrides 'shutdown -t' delay?

Jonathan de Boyne Pollard
In reply to this post by The Wanderer
The Wanderer:

> It's still odd / bothersome that systemd's shutdown would see the
> unsupported / unrecognized '-t' option and just proceed blithely
> along, rather than erroring out on the presumption that a mistake may
> have been made.
>

It's an engineering choice, to not break existing scripts and
documentation that use/give the -t option.  One can understand why
people would make this choice.

Reply | Threaded
Open this post in threaded view
|

systemd ignores / overrides 'shutdown -t' delay?

Jonathan de Boyne Pollard
In reply to this post by The Wanderer
The Wanderer:

> there are plenty of hits explaining how to make systemd inhibit
> shutdown or add a delay or the like, and a few hits related to Debian
> bug 635777 (which seems to be about a delay after the shutdown has
> actually begun, not about a delay in initiating the shutdown), but no
> real useful hints.
>

It's interesting that you didn't spot Debian bug #797763 (a.k.a. systemd
GitHub bug #1120) when looking for Debian bugs relating to shutdown and
times.  It's not the case here, though, as you've discovered.  But you
should have found it.

Reply | Threaded
Open this post in threaded view
|

Re: systemd ignores / overrides 'shutdown -t' delay?

The Wanderer
In reply to this post by Jonathan de Boyne Pollard
On 2015-09-12 at 18:36, Jonathan de Boyne Pollard wrote:

> The Wanderer:
>
>> It's still odd / bothersome that systemd's shutdown would see the
>> unsupported / unrecognized '-t' option and just proceed blithely
>> along, rather than erroring out on the presumption that a mistake
>> may have been made.
>
> It's an engineering choice, to not break existing scripts and
> documentation that use/give the -t option.  One can understand why
> people would make this choice.
I can certainly see the reasoning, though I'm not sure I wouldn't have
come down on the other side of that decision.

Wouldn't it at least make sense to print a message to the effect of
"warning, ignoring unsupported legacy option '-t'", with possibly a
brief comment about what to use in its place (if anything)? That would
have pointed me in the right direction more easily, I think, although I
still wouldn't have gotten there quickly. (That's on me, though.)

Not erroring out is one thing, but succeeding silently and giving
different (and potentially unexpected) behavior is another.

--
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw


signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: systemd ignores / overrides 'shutdown -t' delay?

Ralph Katz
In reply to this post by Jonathan de Boyne Pollard
On 09/12/2015 06:29 PM, Jonathan de Boyne Pollard wrote:
> Ralph Katz:
>
>> There is no "-t" option.
>>
>
> In fact there is.  It's undocumented; and is one of four undocumented
> compatibility options, alongside -a, -f, and -F, that are simply parsed
> and then ignored.  There is a fifth undocumented option with an effect, -K.

"[P]arsed and then ignored" is a valid option?!  You must be a lawyer;
guess I'm now on double-secret probation, heheh...

Regards,
Ralph



signature.asc (546 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

systemd ignores / overrides 'shutdown -t' delay?

Jonathan de Boyne Pollard
In reply to this post by The Wanderer
The Wanderer:

> I can certainly see the reasoning, though I'm not sure I wouldn't have
> come down on the other side of that decision.
>

I actually have done myself, on occasion.


The Wanderer:

> Wouldn't it at least make sense to print a message to the effect of
> "warning, ignoring unsupported legacy option '-t'", with possibly a
> brief comment about what to use in its place (if anything)?
>

Yes, albeit that you won't see me agreeing with that misuse of the word
"legacy", especially when the far better description as a
"compatibility" option is right there in systemd already.  But this
silent behaviour of compatibility options, here and in several other of
the alternative ways to run the "systemctl" program, is something to
take up with the systemd people.


Reply | Threaded
Open this post in threaded view
|

Re: systemd ignores / overrides 'shutdown -t' delay?

David Wright-3
In reply to this post by Jonathan de Boyne Pollard
Quoting Jonathan de Boyne Pollard ([hidden email]):
> Ralph Katz:
>
> >There is no "-t" option.
> >
>
> In fact there is.  It's undocumented; and is one of four
> undocumented compatibility options, alongside -a, -f, and -F, that
> are simply parsed and then ignored.  There is a fifth undocumented
> option with an effect, -K.

May I ask what its effect is?

Cheers,
David.

Reply | Threaded
Open this post in threaded view
|

Systemd ignores / overrides 'shutdown -t' delay?

Jonathan de Boyne Pollard
Ralph Katz:
> There is no "-t" option.

Jonathan de Boyne Pollard:
> In fact there is. It's undocumented; and is one of four undocumented  > compatibility options, alongside -a, -f, and -F, that are simply >
parsed and then ignored. There is a fifth undocumented option with an >
effect, -K.
David Wright:
> May I ask what its effect is?
Reboot the system into a replacement kernel with kexec.  It's from a
System 5 shutdown option that didn't make into the mainstream.

* http://lists.linuxfoundation.org/pipermail/fastboot/2005-June/008429.html