On 02/10/2010 01:22 AM, Wong wrote:
Dear All,
I need a script to check dsl0 availability and restart network daemon if the dsl0 not exist. Then put the script at cron job to run it every 30 minutes
However, I never make BASH script before. Hope you will assist me how to make it.
Thanks a lot for your kind help.
Wong
Wong, At the very basic level and guessing your dsl0 is your internet, all you really need is a ping check to a reliable server that excepts pings and then just check your connection every 60 seconds or so. If it is just for your use, why use cron, just start the check from your ~/.bashrc. Things can get as complicated as you want to make them, but something as simple as: #!/bin/bash runfile=/tmp/chkdsl0.run cleanup() { rm $runfile } trap cleanup trap cleanup SIGINT SIGTERM EXIT if [[ ! -f $runfile ]]; then touch $runfile while :; do if ! ping -q -c1 yahoo.com &>/dev/null; then rcnetwork restart # (as root, or 'sudo rcnetwork restart' with sudo) fi sleep 60 done fi exit 0 call it say 'chkdsl0.sh' and put it in say ~/Documents. Make it executable with chmod +x chkdsl0.sh. Then just call it and background it in your ~./bashrc with the following statement: ~/Documents/chkdsl10.sh & and your will then execute a ping check against yahoo once every 60 seconds and if yahoo.com doesn't respond then you restart the network to regain dsl0. There are a lot of different ways to do this and this is just a very basic solution with a reasonable check to prevent duplicate check process with each start of a new shell that you can expand on. Good luck. -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org