发出重启或关机时,我看到:
[kbrandt@ny-kbrandt01: ~] sudo reboot [sudo] password for kbrandt: Broadcast message from [email protected] (/dev/pts/3) at 14:50 ... The system is going down for reboot NOW!
我可以看到这个特定的string是二进制的一部分:
[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!
但有谁知道是否有一种方法,我可以添加一个提醒信息来沉默我们的监控系统中的主机而不修改二进制文件?
关于shutdown(8)手册页的非常仔细的阅读(即不是我查看的第一次,也没有find任何东西)揭示了可以在命令行上提供自定义消息。
例如:
# 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!
在该说明中,如果您在环境中使用EL7,我build议您提前1分钟安排关机时间,如果您希望看到此消息,而不是“现在”closures,就像我的经验,用户可能会先注销接收墙(由于系统是如此血腥快速closures和启动系统)。
在这个笔记上,如果你想要更快的重启,请在重启之前设置kexec,以免跳过无聊的1到15分钟的服务器自检硬件。
您可以制作写入墙上的服务。 该服务将开始并创build“locking”文件,然后在重新启动或closures时收到消息(对于CentOS 7,由于使用systemd,进程可能不同):
脚本(可能会更好):
[root@ny-kbrandt01 init.d]# cat reminder #!/bin/bash # chkconfig: 2345 99 01 # description: My test service if [[ $1 == "start" ]]; then touch /var/lock/subsys/reminder fi if [[ $1 == "stop" || $1 == "halt" ]]; then wall "Please silence in bosun so Kyle doesn't turn into more of a nutbag" fi
并确保使用chkconfig添加它:
[root@ny-kbrandt01 init.d]# chkconfig --add reminder
问题是,这个版本并没有扩展到“自动沉默”,因为我们不希望这样做,非pipe理员启动的重新启动。
man shutdown
NAME shutdown - bring the system down SYNOPSIS shutdown [OPTION]... TIME [MESSAGE]