If you’re savvy with BASH commands in the mac terminal, download my script files here. If you need a little extra help, read on! Look at the end of this post for a short description of each file in the script to see if it meets your needs.
If you manage multiple websites in your job or freelance work, at times you may need to check whether those websites are live and what IP address they’re pointing to. As a recent example, I had to move about 50 websites to a new server and check daily whether their DNS has propagated to the new IP address. This can be time-taking and tedious!
To check a single site, I usually just use the “ping” command in my terminal (using mac OSX… sorry windows users, if you’re reading this, just take it as a cue to move to a unix based operating system). Okay, so running the ping command can take a long time and be quite tedious if you have to check multiple domains, and as for checking the sites one by one in your browser… Forget about it!
So to solve my problem, I made this nifty pinging script, which you can feel free to use to check your own sites.
If you download the script and related files, then unpack them, here’s how to use them:
- Add the websites you’d like to ping in the file called websites.txt
- Open your mac terminal and run the pingall.sh (in terminal, navigate to the location of the script (“cd /users/yourusername/desktop/ping_script/” and type “sh pingall.sh” and hit enter to run the script, its just that easy)
- wait a for the script to run, it might take a while depending on how many sites you need to ping
- the results will be saved in the file “results.txt” – this file will not get overridden, so if it already exists before running the script, the ping results will be appended to the end of the file.
One note: The default timeout is set to 1 second. In many cases this is not enough time to get a successful response, so the result may show 100% packet loss even if the site is up. At this point you can check the sites with errors individually, or increase the timeout length (which will greatly increase the amount of time the script takes to execute). To increase the timeout length, change the line “timeOut=1” to indicate the number of seconds you want to wait to timeout. (timeout=10 would wait 10 seconds before timing out and moving to the next line of the script).
Also, you can ping just the ip addresses of the sites by executing the pingip.sh instead of the pingall.sh.
Now, here is a brief description of each file:
- pingip.sh – executing this script will ping every website in the file websites.txt and output only the website domain being pinged and IP address
- pingall.sh – executing this script will give you the full ping response of each site listed in websites.txt
- websites.txt – add the sites here you want to ping, each site on a separate line
- results.txt – the output of the ping will be sent to this file. Make sure to clear it out or delete it before a new ping, as the script will not overwrite this file
Good luck! I posted this in a hurry so please comment with any questions. And please let me know if this works for you and saves you time!