Linux is much more mature than it was a few years ago, but sometimes there will still be an inexplicable and undefinable kernel panic situation. For most Linux users, restart the kernel panic, however, for system administrators and hosting service providers who are engaged in virtual hosts, shared hosts, and OpenVZ VPS hosts, unknown kernel panic may not be very friendly if the system fails, if there is no KVM over IP address, the hosting service provider needs to report to the independent server provider at the upper level first, for example, submitting a ticket request or making a phone call, then the independent server supplier needs time to verify your data, process your ticket, and finally to the real data center. Generally, during the daytime in China at night, only a few persons are on duty in the data center, it may have been more than 20 minutes since you finally restarted ticket. During this 20-minute downtime, you have to write a letter to your own customers to explain the situation, the problem is that this 20 minutes is still the ideal situation. If you encounter a very bad independent server provider or data center, ticket processing should be measured in hours or days, or if you are One man, sleeping at night, does not receive a kernel panic alarm, so it takes more time. Is there a way to enable the Linux server to automatically restart the kernel panic? VPSee describes a simple and effective tips:
Edit the/etc/sysctl. conf file and define to automatically restart Linux after 20 seconds of kernel panic:
# vi /etc/sysctl.confkernel.panic = 20
How amazing is Linux? Can I restart the kernel panic automatically if it doesn't work? Let's take a look at how this part of the code works in the Linux kernel. The most authoritative information is always from the kernel source code:
# Vi linux-2.6.31.8/kernel/panic. c
- ...
- if (panic_timeout > 0) {
- /*
- * Delay timeout seconds before rebooting the machine.
- * We can't use the "normal" timers since we just panicked.
- */
- printk(KERN_EMERG "Rebooting in %d seconds..", panic_timeout);
-
- for (i = 0; i < panic_timeout*1000; ) {
- touch_nmi_watchdog();
- i += panic_blink(i);
- mdelay(1);
- i++;
- }
- /*
- * This will not be a clean reboot, with everything
- * shutting down. But if there is a chance of
- * rebooting the system it will be rebooted.
- */
- emergency_restart();
- }
- ...