Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using a script called Responser which sends email when any of the my sites are down/slow. I just wanted to check if it's sending the mail only if the sites are really down or slow(as I checked it accessing as soon I got the error mails and sites was fine). I thought of using wget as it shows the speed and response time and I want to schedule it to compare it with my responser script whether both sends the mail at the same time saying error.

I've postfix installed and I could send mails using mail command to any e-mail id from the terminal. I want the output of wget to be mailed with the condition if response time is greater than 5 seconds. Then I can schedule it to run at every 5 mins. I saw many having good programming skills here and hope someone could help me.


share|improve this question

The script you want is something like this:

# by desgua to test server down
# This script is supposed to be named "" and
# to be put at ~/
# to test what happens when server is down: 
# change for  
# As asked, I supposed you have a script to send mail and named
# ~/ 
sleep 300          # as asked, to run at every 5 minutes
pingtime=$(ping -w 5 | grep ttl)

echo $pingtime

if [ $pingtime = ] ; then 
   echo 'down' ; ~/ ; else
   echo 'up' ; ~/

ps. At your script to send the email, put something to run again the script I made after the mail has been sent

share|improve this answer
The domain names are globally registered but I couldn't ping to them – user3215 Apr 22 '11 at 2:12
PING (204.200.xx.xx) 56(84) bytes of data. ^C ping statistics --- – user3215 Apr 22 '11 at 3:24
No, it's just an output of ping – user3215 Apr 22 '11 at 4:16
I have firewall settings on my server and so it won't ping – user3215 Apr 24 '11 at 4:16
You sure know how to configure it to allow ping, right? You don't want to allow ping or you need help to configure it? – desgua Apr 24 '11 at 11:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.