1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

a simple bash script for checking dead/alive domains

Discussion in 'General Programming Chat' started by Rushdie, Oct 23, 2011.

  1. Rushdie

    Rushdie BANNED BANNED

    Joined:
    Feb 2, 2009
    Messages:
    1,378
    Likes Received:
    1,720
    Code:
    #!/bin/bash
    retries=3
    	while read url; do
    		errors=0
    			for (( i = 1; i <= retries; i++ ));
    			do
    				  wget -q "$url"
    				  if [ $? -ne 0 ]; then
    					let errors++
    					sleep 60
    				  else
    					i=$retries
    				  fi
    			done
    		if [ $errors -eq $retries ]; then
    			echo "$url" >> sites-down.txt
    		fi
    	done < url.txt
    ./script.sh and should work
    the script takes each domain from url.txt and checks it with wget -q. if the website is up wget -q returns nill. it takes all the domains for which wget -q produced output for each of the number of retries and puts them in the file sites-down.txt

    i manage >2000 domains so its hard to do this manually or with any other web service (would cost a lot)

    actually the site might be broken and wget might return nothing, so this tool is basicly only useful to find out about: dns problems, hosting problems, database connection problems. I actually use it to check which domains and servers are set up ok when im adding a few hundred sites at a time so it really helps :)