Solved

check wget system

Posted on 2011-03-16
2
471 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 250 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 250 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

786 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