I am using SUSE 10.1, and my Wireless Network card (a Belkin RT2500, I believe) is running quite well using the NDisWrapper... but every once in a while, it drops connection. I wrote a shell script as root to check for network connectivity, and if it isn't there, the script is supposed to kill all occurances of NetworkManager (since I use KNetworkManager to manage my wlan0). The script follows:
Code:
#!/bin/bash
mytest=$(ping -c 1 192.168.1.1 | grep -c time);
if [ "$mytest" == 2 ];
then
date;
echo "----- System is cool!";
else
mypid=$(pgrep NetworkManager);
kill $mypid;
sleep 2s;
NetworkManager;
date;
echo "----- System Down - Resetting";
fi
Problems (2 total):
Number 1: If it cannot ping the router and there is already a NetworkManager PID (stored in mypid), it successfully kills NetworkManager, but won't successfully restart the process after the 2 second pause.
Number 2: If there isn't already a NetworkManager PID, it successfully starts a process if I run the script from the command line, but will not start the process if launched from the crontab:
Code:
*/5 * * * * /root/KeepConnectionAlive.sh
Can anyone help me find trouble shoot this script? Should I back off from Suse and use something different?