I sometimes have a need to take down a Linux host “hard”, that is, without the normal shutdown scripts. Among other methods, I accomplish this with:
This is suboptimal (risks corruption), but it does the job. The hosts in this case have kernel modules that the normal “rmmod” would hang on forever, and since they have no console/ILO or IPMI or other power control I am forced to use this or some other trick to take down (reboot -f or sending a NOC person out on the floor are the other common methods, the latter being our last resort).
Because this immediately forces the kernel to reboot (assuming you have the “Magic SysRq” option in your kernel), using ssh becomes a problem, as the TCP connection dies without you getting a RST packet, so normal ssh and TCP timeout mechanisms apply, and it’ll take a few minutes for the host to come back up and issue a TCP RST in response to a keep alive message for that connection.
Now, every once in awhile I do something without giving it enough thought. That’s a kind way of saying I do something really dumb. Imagine, if you will trying to reboot a lot of machines via an “at” job. Further imagine that you decided to change your normal reboot/shutdown -r to the aforementioned sysrq-trigger trick.
Also interesting is that using sysrq-trigger doesn’t allow the at job to be removed from the queue before the machine is restarted, and will just say there until the job is allowed to exit normally.
I think you see what I did. Dumb. Thankfully there are a few seconds available between boot and when the job runs to remove the job from the queue.