4

Where can I find information about if there is an reboot scheduled and in that case: when, why and by who?


I got this in my terminal:

Broadcast message from root@my-server (Tue 2017-11-07 09:00:00 CET):

The system is going down for reboot at Wed 2017-11-08 02:00:00 CET!

So in a couple of hours the system will be rebooted, that's good. But after working for a while and the message is scrolled out of visibility or if the terminal is closed:

How can I get hold of the reboot time?

If I again login to the server I only get the message:

*** System restart required ***

There is no information about the upcoming reboot. I have tried to see if there is any shutdown processes running, but could not find any.

I know I could produce a similar message by issuing a command like this:

sudo shutdown -r 02:00

So, how do I find information about any upcoming reboots?

3 Answers 3

4

On an Ubuntu 18.04 machine shutdown is managed by systemd. On my machine I have enabled automatic reboots via unattended upgrades:

$ grep Automatic-Reboot /etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "02:00";

The scheduled automatic reboot time is stored in /run/systemd/shutdown/scheduled.

$ cat /run/systemd/shutdown/scheduled
USEC=1563976800000000 
WARN_WALL=1
MODE=reboot

You can convert this to a human readable time using the following command:

$ date -d "@$( awk -F '=' '/USEC/{ $2=substr($2,1,10); print $2 }' /run/systemd/shutdown/scheduled )"
Thu Jul 25 02:00:00 NZST 2019
2

As started with sudo shutdown -r 02:00 it's not a file / setting / system variable / crontab entry. The shutdown is a process and if it's still pending, you should see it.

$ ps -ef | grep shutdown
root      3155  2941  0 12:04 pts/4    00:00:00 sudo shutdown -r 02:00
root      3156  3155  0 12:04 pts/4    00:00:00 shutdown -r 02:00
esa       3158  2937  0 12:04 pts/3    00:00:00 grep shutdown

If it's cancelled with external command sudo shutdown -c or by pressing ^C in pts/4, the process will show a message Shutdown cancelled. and exit. So if it's not there:

  • someone has cancelled the shutdown after the message.
  • the message was produced with shutdown -k (Don't really shutdown; only send the warning messages to everybody. In some versions this also prevents new logins.)
  • you are running ps with a user account that doesn't see processes of other users.
1
  • 1
    Point1, I get a new message every hour. So no, I don't think so. Point2, why would the system fool me like that? Point3, no thats not the case: sudo ps aux | grep shutdown gives me no response.
    – UlfR
    Nov 7, 2017 at 10:41
2

On my Ubuntu machines, the 'reboot required' message upon login comes from the file at /var/run/reboot-required. This file is removed during the update/reboot process.

The reboot time is set with Unattended-Upgrade::Automatic-Reboot-Time in the /etc/apt/apt.conf.d/50unattended-upgrades file.

As Esa stated, the broadcast message was most likely produced by something else executing shutdown -k, which only prints the message and exits. I also observe the broadcast messages, but afterwards, sudo ps faux shows me no shutdown processes that are running.

It's worth noting that even though no shutdown process stays running, something does seem to keep track of when the original shutdown time was scheduled. Even when I change the value for reboot time, subsequent broadcast messages still show me the originally configured time.

You must log in to answer this question.

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