When issuing a reboot or shutdown I see:

[kbrandt@ny-kbrandt01: ~] sudo reboot
[sudo] password for kbrandt:

Broadcast message from kbrandt@ny-kbrandt01.ds.stackexchange.com
    (/dev/pts/3) at 14:50 ...

The system is going down for reboot NOW!

I can see that this particular string is part of the binary:

[kbrandt@ny-kbrandt01: ~] strings /sbin/shutdown | grep NOW
The system is going down for power off NOW!
The system is going down for halt NOW!
The system is going down for maintenance NOW!
The system is going down for reboot NOW!

But does anyone know if there is a way I could add a reminder message to silence the host in our monitoring system without modifying the binary?

  • On 7 everyone often gets logged out before the wall goes out anyway. – Michael Hampton Nov 25 '14 at 14:58
  • Wouldn't you want to know in your monitoring system that it is rebooting? Or does the new monitoring system throw up 100 alarms during the reboot? – TheCleaner Nov 25 '14 at 15:02
  • @TheCleaner: It will throw at least a alarm mostly likely (and that is false alarm if someone has run the shutdown command). – Kyle Brandt Nov 25 '14 at 17:16

A very careful reading of the shutdown(8) man page (i.e. not the first couple of times I looked and didn't find anything) reveals that a custom message can be provided on the command line.

For instance:

# shutdown -r +15 "We're rebooting for unicorns. Silence monitoring please."
Shutdown scheduled for Tue 2014-11-25 10:17:53 EST, use 'shutdown -c' to cancel.
Broadcast message from root@saurok (Tue 2014-11-25 10:02:53 EST):

We're rebooting for unicorns. Silence monitoring please.
The system is going down for reboot at Tue 2014-11-25 10:17:53 EST!

On that note, if you have EL7 in the environment, I recommend you schedule your shutdowns for 1 minute ahead, if you want this message to be seen, rather than shutting down "now", as in my experience users may be logged out before receiving the wall (due to systemd being so bloody fast to shutdown and start up the system).

On that note, if you want even faster reboots, set up kexec before you reboot, to skip the boring 1 to 15 minutes of the server self-testing its hardware...

  • Sorry if my goal isn't clear. The idea is that if someone types "shutdown" that person gets a message on the screen that reminds them to put the box in maintenance on the host. So the person performing the shutdown wouldn't be adding the message – Kyle Brandt Nov 25 '14 at 17:15
  • @KyleBrandt I think you'll have to write your own wrapper scripts for that. Then you could get really creative and just have the wrapper talk to the monitoring server and put the box in maintenance mode itself. – Michael Hampton Nov 25 '14 at 17:24
  • Tried making an init script that writes to the wall on runlevel 0/6 , however it looks like the disconnect from ssh happens faster than the wall write (even though the reminder script is K01 and sshd is K25), guessing these are not serial .... – Kyle Brandt Nov 25 '14 at 18:22
  • Ah nevermind, just needed to make the sys lock – Kyle Brandt Nov 25 '14 at 18:28

You can make a service that writes to the wall. The service will get started and create the "lock" file, and then you will get the message when rebooting or shutting down (Process is probably different for CentOS 7 since it uses systemd):

Script (Could probably be better):

[root@ny-kbrandt01 init.d]# cat reminder
# chkconfig: 2345 99 01
# description: My test service

if [[ $1 == "start" ]]; then
        touch /var/lock/subsys/reminder

if [[ $1 == "stop" || $1 == "halt" ]]; then
        wall "Please silence in bosun so Kyle doesn't turn into more of a nutbag"

And be sure to add it with chkconfig:

[root@ny-kbrandt01 init.d]# chkconfig --add reminder

The problem is that this version doesn't scale as well having it "auto silence" because we wouldn't want to do that for non-admin initiated reboots.


man shutdown

   shutdown - bring the system down

   shutdown [OPTION]...  TIME [MESSAGE]
  • From what operating system is this man page? – Michael Hampton Nov 25 '14 at 15:00
  • CentOS release 6.6 (Final) – hymie Nov 25 '14 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.