You need to reboot a Linux server, but the ‘reboot’ and ‘shutdown’ commands aren’t working, perhaps because of pending disk writes, etc.
There is a rather ingenious solution for this. Cause a kernel panic in a way that forces a reboot. This should only be done if everything else fails and you simply can’t get the server to reboot.
- Log into the box as root
- Run the following commands:
# echo 1 > /proc/sys/kernel/panic
# cat /dev/zero > /dev/mem
- This will cause an immediate reboot.
What did we do here? We told Linux to reboot rather than halt on a kernel panic via panic sysctrl and then we blew away memory which the kernel detects and causes a kernel panic. And there you go!