Networking

Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.

Applications

Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.

Data

Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.

Monitoring

Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Commands & Shells

Autorebooting Servers on Low or High Load

Submitted by on September 14, 2011 – 5:03 pm 3 Comments

Recently I ran into a situation where I needed to reboot several HPC cluster compute nodes. A couple of systems were still running user jobs that I did not want to interrupt. I also didn’t want to sit around and watch those jobs, as there was no way of telling how long they could take to complete. The solution was to write a short script that looks something like this:

#!/bin/ksh
while [ `uptime | awk '{print $10}' | awk -F'.' '{print $1}'` -ge 1 ]
do
        wait
done
echo "Autorebooting node `hostname` on low CPU utilization." | mailx -s "Autoreboot of `hostname` in progress" my.cell@att.com
/sbin/reboot -f

The script should be executed as follows:

nohup /full/path/to/script/script.ksh &

The idea is simple: the script runs in the background even after you log out; it monitors system load, which in our case will always be above 1 as long as user jobs are running. As soon as system load falls below 1, the script executes a forced reboot. You don’t need to do a forced reboot unless you have some persistent problems with your systems doing a graceful shutdown. In my case the problem has to do with PANFS filesystems hanging on unmount. A forced reboot is a sure way to restart the system and any disk corruption is usually fixed automatically during boot up. But your situation may be different, so don’t use “reboot -f” unless you have to.

Print Friendly, PDF & Email

3 Comments »

  • Ev dog says:

    How can I reboot my computer to erase a program I recently downloaded?

  • Dr Dorian says:

    I have some computer equipment at customer locations scattered around the state. Does anyone know how I can reboot my equipment when internet access is not available or down?

  • Jeanelle the Retard says:

    I’m trying to use software to erase the information on my old computer before donating it. The mouse is not working on the computer. I’ve tried another mouse on the computer and it still will not work. I need to reboot my computer in order to start the disc wiper. Is there a way of rebooting my computer without a mouse? Thanks so much!

Leave a Reply

%d bloggers like this: