Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

check wget system

Posted on 2011-03-16
2
Medium Priority
?
479 Views
Last Modified: 2013-12-16
hello there,
I would like to check a website to see if its alive with wget.. for example
"wget mysite.com" every minute and if it doesnt respond send me an email..
but im having a little issue and sometimes the site doesnt answer and times out..
how can I create a little script for this? thanks
0
Comment
Question by:XK8ER
2 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 1000 total points
ID: 35145823
#!/bin/sh
if ! wget --tries=1 --spider -O /dev/null mysite.com >/tmp/wgetlog.$$ 2>&1
    then
      mailx -s "Error occurred with  mysite.com" XK8ER@domain.tld < /tmp/wgetlog.$$
fi
rm -f /tmp/wgetlog.$$
exit

Run it via cron on a regular basis.

wmp
0
 
LVL 3

Assisted Solution

by:Alberto Cortes
Alberto Cortes earned 1000 total points
ID: 35149520
You can use next script:

if ! wget --timeout=60 --spider -o /dev/null http://mysite/index.html
then mailx -s "timeout error with http://mysite" user@email
fi


This will check URL and you control the timeout in seconds. Notice that timeout can be DNS lookup delay, connect dealy, and read delay.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month7 days, 11 hours left to enroll

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question