Server Watchdog

This is a followup to this post. It seems there’s a more graceful option to reboot the server when there are problems.

These instructions are for debian

1. Add the following lines to /etc/sysctl.conf

2. server:~# apt-get install watchdog

3. In /etc/watchdog.conf, uncomment the following:

[ You may want to play with some of the other settings, most
notibly ping. I didnt have luck with it, however. My server
constantly rebooted ]

4. server:~# /sbin/modprobe softdog

5. add the following to /etc/modules

6. Reboot

Bash Restart on Network Failure

[UPDATED INFORMATION]

Here’s a bash script I’m using on my server to restart the server in the event network goes down.  I set this up because, during a large file transfer through Samba, the server’s network stopped responding.  To be on the safe side, I’m doing a full restart.

The scripts attempt to ping HOST (192.168.1.1, my router), MAX_FAILURES (3) times.  After the 3rd failure, the server will restart.  If the network comes back before the restart, we’ll proceed as if nothing happened.  I’m waiting 5 minutes between each attempt.

I’m running this through an hourly cronjob.