MoinMoin Logo
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Navigation

  • Start
  • Sitemap
Revision 3 as of 2013-06-27 08:44:04
  • CheckConnection

Check connection

Simple script to check connection to a host, that in case of failure asks for new IP address through DHCP.

Add entry to crond of account with privileges to get address through dhclient:

  • chmod 755 /<folder>/checkConnection.sh

  • crontab -e
  • * * * * * /<folder>/checkConnection.sh

   1 #!/bin/sh
   2 PROG=checkConnection
   3 HOST=dns.sedimap.pvt
   4 ping $HOST -c 5 > /dev/null 
   5 RES=$?
   6 if [ $RES -eq 0 ]; then
   7   logger "$PROG: Ping to $HOST OK"
   8 else
   9   logger "$PROG: Ping to $HOST NOK, running dhclient eth0"
  10   dhclient eth0 -v
  11   # other seervices that may need restarting
  12 fi

On Slackware the logger output should apper on /var/log/messages.

  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01