Detect pending linux shutdown

iGEL picture iGEL · Feb 19, 2011 · Viewed 8.3k times · Source

Since I install pending updates for my Ubuntu server as soon as possible, I have to restart my linux server quite often. I'm running an webapp on that server and would like to warn my users about the pending restart. Right now, I do this manually, adding an announcement before the restart, give them some time to finish their work, restart and remove the announcement.

I hope, shutdown -r +60 writes an file with all the information about the restart, which I can check on every access. Is there such a file? Would prefer a file in a virtual file system like /proc for performance reasons...

I'm running Ubuntu 10.04.2 LTS

Answer

8.8.8.8 picture 8.8.8.8 · Jul 11, 2018

If you are using systemd, the following command shows the scheduled shutdown info.

cat /run/systemd/shutdown/scheduled