<br><br><div class="gmail_quote">On Thu, Feb 10, 2011 at 1:20 PM, Chuck Payne <span dir="ltr">&lt;<a href="mailto:terrorpup@gmail.com">terrorpup@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Guys,<br>
<br>
I have a script that does a wget, but if a server is not responing,<br>
the the script deads. What is the best way to say if host x doesn&#39;t<br>
return a value after 10 sec to stop.  I seen several example of<br>
timeout function, but it looks I need to write a pid is that true?<br></blockquote><div><br>This uses fping, I used it to backup machines on the lan which aren&#39;t on all the time.  <br> </div>$ cat /tmp/ptest.sh <br>#!/bin/bash<br>
#HOSTS=&quot;xp darwin&quot;<br>HOSTS=&quot;xp u2&quot;<br>for h in $HOSTS<br>do<br>  fping -u $h &gt;&amp; /dev/null<br>  if [ $? -ne 0 ]; then<br>          echo ${h} host is down <br>          #echo ${h} host is down send email `date` &gt;&gt; /var/log/backup-hosts.log<br>
          # mail -s &quot;Host ${h} down&quot; <a href="mailto:admin@example.com">admin@example.com</a><br>else<br>          echo $h is up<br>          #echo  ${h} host backup run `date` &gt;&gt; /var/log/backup-hosts.log<br>
          #/usr/local/sbin/backup-$h-to-u2.sh<br>  fi<br>done<br><br>$ bash /tmp/ptest.sh <br>xp host is down<br>u2 is up<br></div><br><br>I changed the way I do the backups, and I am still looking into how I will redo the backups for the windows machines.<br>
<br>Chuck<br>