The following script will allow the user to specify a site to ping and the number of hours to repeat the experiment. For example,
pinger www.google.com 48
will ping Google's web server for 30 seconds once an hour for 48 hours (2 days). At the end of the experiment, the results will be emailed to the address specified. Modify parameters as needed to vary the length of each ping or the time between ping's.
To use this script, execute permissions must be enabled.
#!/bin/bash
# $1 = site to ping, $2 = number of hours, $3 = email address
declare -i count=0 fname="$1.ping" echo -n > $fname while [ $count -lt $2 ] do date >> $fname ping -c 30 $1 | tail -n 2 >> $fname echo >> $fname count=$count+1 sleep 3600 done
mail -s "ping results for $1" $3 <$fname