Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to check for scheduled shutdown

168 views
Skip to first unread message

Urs Thuermann

unread,
Nov 22, 2022, 7:30:06 AM11/22/22
to
After shutdown -h <time> I see no way to see this scheduled shutdown.
Before systemd, I could always see the shutdown process with its
arguments using ps(1).

Now, the call to shutdown returns to the shell immediately leaving no
process. It probably communicates to the init process 1, but, as
usual for systemd, very little or nothing seems to be documented. Or
at least it's hidden, so that you cannot find it in reasonable time.

I couldn't find any relevant differences with and without a scheduled
shutdown in the output of systemctl status --all and systemctl show --all.

urs

David Wright

unread,
Nov 22, 2022, 9:50:06 AM11/22/22
to
There's a file, "scheduled", that's created in /run/systemd/shutdown,
which contains the time, noisiness and destiny of the shutdown.
I haven't tried editing, say, the noisiness, to see whether I can stop
the flow of Wall messages on all my xterms.

Cheers,
David.

to...@tuxteam.de

unread,
Nov 22, 2022, 10:00:06 AM11/22/22
to
On Tue, Nov 22, 2022 at 08:48:25AM -0600, David Wright wrote:

[...]

> There's a file, "scheduled", that's created in /run/systemd/shutdown,
> which contains the time, noisiness and destiny of the shutdown.
> I haven't tried editing, say, the noisiness, to see whether I can stop
> the flow of Wall messages on all my xterms.

*My* shutdown has a command line option (-Q) for the latter. Dunno about
yours ;-)

Cheers
--
t
signature.asc

David Wright

unread,
Nov 22, 2022, 10:20:54 AM11/22/22
to
# shutdown -Q +15
shutdown: invalid option -- 'Q'
#

But I meant in arrears, hence the "say".

I still haven't tried editing, say, the MODE=poweroff to MODE=reboot,
in order to see whether the file is only written, or read at intervals
as well. I might have done if I hadn't already started my browser, and
other miscellaneous tasks.

Cheers,
David.

Charles Curley

unread,
Nov 22, 2022, 11:00:05 AM11/22/22
to
On Tue, 22 Nov 2022 09:09:56 -0600
David Wright <deb...@lionunicorn.co.uk> wrote:

> > > I haven't tried editing, say, the noisiness, to see whether I can
> > > stop the flow of Wall messages on all my xterms.
> >
> > *My* shutdown has a command line option (-Q) for the latter. Dunno
> > about yours ;-)
>
> # shutdown -Q +15
> shutdown: invalid option -- 'Q'
> #

According to the man page for shutdown, --no-wall should do that.


--no-wall
Do not send wall message before halt, power-off, reboot.



--
Does anybody read signatures any more?

https://charlescurley.com
https://charlescurley.com/blog/

to...@tuxteam.de

unread,
Nov 22, 2022, 12:30:09 PM11/22/22
to
On Tue, Nov 22, 2022 at 09:09:56AM -0600, David Wright wrote:
> On Tue 22 Nov 2022 at 15:56:48 (+0100), to...@tuxteam.de wrote:
> > On Tue, Nov 22, 2022 at 08:48:25AM -0600, David Wright wrote:
> >
> > [...]
> >
> > > There's a file, "scheduled", that's created in /run/systemd/shutdown,
> > > which contains the time, noisiness and destiny of the shutdown.
> > > I haven't tried editing, say, the noisiness, to see whether I can stop
> > > the flow of Wall messages on all my xterms.
> >
> > *My* shutdown has a command line option (-Q) for the latter. Dunno about
> > yours ;-)
>
> # shutdown -Q +15
> shutdown: invalid option -- 'Q'
> #

Ah, that Other Init System. Moving fast and breaking things ;-)

> But I meant in arrears, hence the "say".

I see.

Hm. With SysV, you can't either (spoiler alert: the shutdown process
itself is the one doing the timing by sleeping until fulfillment of
its task). But you always can cancel it (shutdown -c with SysV, dunno,
again, with systemd).

> I still haven't tried editing, say, the MODE=poweroff to MODE=reboot,
> in order to see whether the file is only written, or read at intervals
> as well. I might have done if I hadn't already started my browser, and
> other miscellaneous tasks.

That would be a nice experiment, yes :-)

Cheers
--
t
signature.asc

Greg Wooledge

unread,
Nov 22, 2022, 12:40:05 PM11/22/22
to
On Tue, Nov 22, 2022 at 06:22:57PM +0100, to...@tuxteam.de wrote:
> Hm. With SysV, you can't either (spoiler alert: the shutdown process
> itself is the one doing the timing by sleeping until fulfillment of
> its task). But you always can cancel it (shutdown -c with SysV, dunno,
> again, with systemd).

The systemd shutdown(8) man page has a -c option for canceling a pending
shutdown. I have not tested this.

to...@tuxteam.de

unread,
Nov 22, 2022, 2:20:05 PM11/22/22
to
On Tue, Nov 22, 2022 at 12:29:49PM -0500, Greg Wooledge wrote:
> On Tue, Nov 22, 2022 at 06:22:57PM +0100, to...@tuxteam.de wrote:
> > Hm. With SysV, you can't either [change the time, but you can cancel]

> The systemd shutdown(8) man page has a -c option for canceling a pending
> shutdown. I have not tested this.

Thanks :)

Cheers
--
t
signature.asc

Kamil Jońca

unread,
Nov 22, 2022, 2:40:05 PM11/22/22
to
Urs Thuermann <u...@isnogud.escape.de> writes:

> After shutdown -h <time> I see no way to see this scheduled shutdown.
> Before systemd, I could always see the shutdown process with its
> arguments using ps(1).

Hm.
kjonca@alfa:~%man shutdown
SHUTDOWN(8) shutdown SHUTDOWN(8)

NAME
shutdown - Halt, power off or reboot the machine
[...]
OPTIONS
[...]
--show
Show a pending shutdown action and time if there is any.

kjonca@alfa:~%sudo shutdown --show
No scheduled shutdown.

Am I overlooked something?

--
http://wolnelektury.pl/wesprzyj/teraz/

to...@tuxteam.de

unread,
Nov 22, 2022, 3:10:06 PM11/22/22
to
Ah, this one, again, from the systemd side...

Although, on the SysV side one could try to limp along with
something like

sudo cat /proc/$(cat /var/run/shutdown.pid)/cmdline

:-)

(Now the explicit path of shutdown's PID might be in itself a
Debianism)

Cheers
--
t
signature.asc

Sven Joachim

unread,
Nov 22, 2022, 3:20:05 PM11/22/22
to
Perhaps that the --show option was only added in systemd 250 and is not
available in Bullseye and older Debian releases.

Cheers,
Sven

Charles Curley

unread,
Nov 22, 2022, 4:20:05 PM11/22/22
to
On Tue, 22 Nov 2022 21:11:55 +0100
Sven Joachim <sven...@gmx.de> wrote:

> > kjonca@alfa:~%sudo shutdown --show
> > No scheduled shutdown.
> >
> > Am I overlooked something?
>
> Perhaps that the --show option was only added in systemd 250 and is
> not available in Bullseye and older Debian releases.

I certainly don't see it on Bullseye.

root@ideapc:~# cat /etc/debian_version
11.5
root@ideapc:~# shutdown --show
shutdown: unrecognized option '--show'
root@ideapc:~#

Ximo

unread,
Nov 22, 2022, 4:20:05 PM11/22/22
to
El 22/11/2022 a las 13:23, Urs Thuermann escribió:
> After shutdown -h <time> I see no way to see this scheduled shutdown.
> Before systemd, I could always see the shutdown process with its
> arguments using ps(1).
>

# date --date @$(head -1 /run/systemd/shutdown/scheduled |cut -c6-15)

Urs Thuermann

unread,
Nov 22, 2022, 4:40:06 PM11/22/22
to
Kamil Jońca <kjo...@o2.pl> writes:

> kjonca@alfa:~%man shutdown
> SHUTDOWN(8) shutdown SHUTDOWN(8)
>
> NAME
> shutdown - Halt, power off or reboot the machine
> [...]
> OPTIONS
> [...]
> --show
> Show a pending shutdown action and time if there is any.
>
> kjonca@alfa:~%sudo shutdown --show
> No scheduled shutdown.
>
> Am I overlooked something?

On my machine, the man page doesn't mention --show.

$ cat /etc/debian_version
11.5
$ man shutdown | tail -n1
systemd 247 SHUTDOWN(8)
$ /sbin/shutdown --show
/sbin/shutdown: unrecognized option '--show'


urs

Greg Wooledge

unread,
Nov 22, 2022, 4:40:06 PM11/22/22
to
That looks quite fragile. If the output format changes even slightly,
it'll start to give wrong answers.

In order to offer a better solution, I'd need to *see* one of these
files. Which in turn apparently means I need to generate one. So I guess
I get to test that "cancel" option after all.

unicorn:~$ sudo shutdown -r 23:59
[sudo] password for greg:
Reboot scheduled for Tue 2022-11-22 23:59:00 EST, use 'shutdown -c' to cancel.
unicorn:~$ cat /run/systemd/shutdown/scheduled
USEC=1669179540000000
WARN_WALL=1
MODE=reboot

OK. I can work with that.

unicorn:~$ date -d @"$(awk -F= '/^USEC=/ {print $2/1000000}' /run/systemd/shutdown/scheduled)"
Tue Nov 22 23:59:00 EST 2022
unicorn:~$ sudo shutdown -c
unicorn:~$ cat /run/systemd/shutdown/scheduled
cat: /run/systemd/shutdown/scheduled: No such file or directory

Ironically, the "sudo shutdown -c" command blasted a message onto every
terminal EXCEPT the one where I ran the command. Rather annoying.

A solution built around "dotting in" the file in a shell would also work,
but that's quite a bit more dangerous if the output format changes, or if
I'm only seeing a "best case scenario" here. Before going there, I would
want to check the systemd source code to see whether this file is written
in a way that's guaranteed to be safe for a shell to dot in. That's more
effort than I care to put into this right now.

Kamil Jońca

unread,
Nov 22, 2022, 4:50:05 PM11/22/22
to
Sven Joachim <sven...@gmx.de> writes:

[...]
>
> Perhaps that the --show option was only added in systemd 250 and is not
> available in Bullseye and older Debian releases.
>
> Cheers,
> Sven

Ach, indeed. Sorry.
KJ

--
http://wolnelektury.pl/wesprzyj/teraz/

Anssi Saari

unread,
Nov 23, 2022, 4:30:06 AM11/23/22
to
Sven Joachim <sven...@gmx.de> writes:

> Perhaps that the --show option was only added in systemd 250 and is not
> available in Bullseye and older Debian releases.

Except as a backport, Bullseye backports has systemd 251.3.

songbird

unread,
Nov 23, 2022, 2:40:06 PM11/23/22
to
it has always worked for me.


songbird
0 new messages