How to set up atomatic Linux reboot if kernel panic occurs?
Question: How can I get my Linux server rebooted/restarted automatically if it caught a kernel panic?
Answer: As you might know, kernel panic is an action taken by an operating system upon detecting an internal fatal error from which it cannot safely recover; the term is largely specific to Unix and Unix-like systems (it’s a wiki’s description).
By default Linux wouldn’t not reboot after panic occurs, but the following option of sysctl will cause a kernel to reboot after N seconds you specify. In our example server will be rebooted in 15 seconds if kernel panic stopped its operation:
1. Open sysctl’s configuration file:
sudo nano /etc/sysctl.conf
sudo nano /etc/sysctl.conf
2. Add there the following line:
kernel.panic = 15
kernel.panic = 15
or
1. Execute the following command:
/sbin/sysctl -w kernel.panic=15
/sbin/sysctl -w kernel.panic=15
Hope it helps!