"sudo -i" is irrelevant. The logic lies in adding to cron a timing from 2-8, that executes the script every minute or 5 minutes whicheva u like. I had made a script for similar purpose. Here's the modified one for ur use.
Quote:
#!/bin/bash
cd /home/scripts/
ping 208.67.222.222 -c 1 > /dev/null
val=`echo $?`
if [ $val -ne 0 ];then
echo "--> Restarting" >> autostart.log
date >> autostart.log
echo "******************" >> autostart.log
#Command that starts the connection, you can edit this
/sbin/ifup dsl0
fi
|
1. Save n Name the script say, "nightrider.sh" to a folder say, "/home/scripts" where all ur other scripts are stored.
2. command "chmod +x nightrider.sh" for making it executable
3. For cron u do
Quote:
|
*/5 2-8 * * * /home/scripts/nightrider.sh
|
The IP 208.67.222.222 belongs to opendns. It is only there for checking the internet connection status. "autostart.log" is the log generated that shows "when" the script was executed. I hope it works!