1

About man shutdown at:

it indicates:

   ...
   The first argument may be a time string (which is usually "now").
   Optionally, this may be followed by a wall message to be sent to
   all logged-in users before going down.
   ...
   Note that to specify a wall message you must specify a time
   argument, too.
   ...

Note this post is about the wall message to be broadcast to all the logged users.

Therefore using the following pattern as follows:

shutdown <time> ["something to share"]

Where <time> can be +1, ... +5, ... +15, therefore from the +1 to +15 range - it as follows:

shutdown +1 ["something to share"]
...
shutdown +5 ["something to share"]
...
shutdown +15 ["something to share"]

I can confirm the other users that are logged receive - appears in their tty - the broadcast message (including or not the custom message according the case). Therefore as the documentation indicates, the message is broadcast. Until here no reason to create this post.

Situation: the reason, I did realise - if <time> is equals or greater than 16 minutes - used through either +16 or hh:mm the message is not broadcast to the other logged users in their tty. For example if date command returns 00:10 then with shutdown 00:26 ... this situation happens. Of course, if is used shutdown 00:15 all work as expected.

Question

  • Why the wall message is not broadcast to all logged users if the time is equals or greater than 16 minutes? - Is it normal or is a bug?

Through either the man shutdown or shutdown --help theoretically the wall message must be always broadcast to all the logged users, it does not matter the range of time about "from now" +15, +20 etc ...

Note I have this situation in many Virtual Machines - for different hosts - for Ubuntu Server 20.04

2
  • 1
    Did you try to see what happens if you use shutdown +20 and wait five minutes? I haven't tried that in a while so not sure, but I seem to recall it walls more often when time is running out and more rarely (or not at all) when there's more time left.
    – ilkkachu
    Apr 17, 2022 at 8:55
  • 1
    I added the systemd tag, because this is relevant only for systemd (which Ubuntu 20.04 uses), as I wrote at the end of the answer.
    – A.B
    Apr 17, 2022 at 9:15

1 Answer 1

3

The information is buried in systemd's sources in src/login/logind-utmp.c:

Warn immediately if less than 15 minutes are left (when the command is run):

/* Warn immediately if less than 15 minutes are left */
if (elapse - n < 15 * USEC_PER_MINUTE) {
        r = warn_wall(m, n);
        if (r == 0)
                return 0;
}

As for when there are warning sent at other times, it's a fixed list of possible remaining minutes before action:

static const int wall_timers[] = {
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
        25, 40, 55, 70, 100, 130, 150, 180,
};

So if you run for example (-k for fake):

shutdown -k +41 test; sleep 62; shutdown -c

You'll see a broadcast shutdown message 1mn after and it will be cancelled 2 more seconds after. Using -k +40 won't send a message immediately though.


The systemd variant of shutdown(8) only tells:

Optionally, this may be followed by a wall message to be sent to all logged-in users before going down.

It doesn't document that such message will be sent when the command is run or repeated before shutdown (even if it is), only that it will be sent before going down.

By comparision the sysvinit shutdown was documented differently and hopefully the implementation followed the documentation:

-q

Reduce the number of warnings shutdown displays. Usually shutdown displays warnings every 15 minutes and then every minute in the last 10 minutes of the countdown until time is reached. When -q is specified shutdown only warns at 60 minute intervals, at the 10 minute mark, at the 5 minue mark, and when the shutdown process actually happens.

2
  • Huge thanks, valuable the code shared. - Pls consider give your support about the -k option at unix.stackexchange.com/questions/699323/… Apr 17, 2022 at 15:19
  • I saw the other question later, but imho its answer can't just rely about solid facts (sources) like this one. So I'd rather not attempt. My example of -k use looks to me like what it's intended for: testing.
    – A.B
    Apr 17, 2022 at 15:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .