Created
March 15, 2013 00:39
-
-
Save joshavant/5166573 to your computer and use it in GitHub Desktop.
page_monitor.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Super quick-n-dirty, cronable bash script to monitor webpage changes and notify via email | |
| # Discussion: | |
| # For every site, sanity check this whole script by running it twice while the page hasn't changed. | |
| # (Due to md5 hashing, this script won't work with any site that serves up a dynamic content body.) | |
| # | |
| # The host must be able to send email via `mail`. | |
| # I used this guide to get up and running in ~5 minutes: | |
| # http://library.linode.com/email/exim/send-only-mta-debian-6-squeeze | |
| url="http://foo.com/bar" | |
| emailAddress="1234567890@txt.att.net" # trick to support cell phone updates! | |
| hashFile="/home/josh/pagecheck_mt.md5" | |
| currentMD5=$(wget -q -O - $url | md5sum | cut -d ' ' -f 1) | |
| if [ -f $hashFile ]; | |
| then | |
| previousMD5=$(cat $hashFile | cut -d ' ' -f 1) | |
| if [ "$currentMD5" != "$previousMD5" ]; | |
| then | |
| mail -s "UPDATED: $url" $emailAddress < /dev/null 2> /dev/null | |
| fi | |
| fi | |
| echo $currentMD5 > $hashFile |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Set up a cronjob like so, to check for page changes every minute:
* * * * * /foo/bar/page_monitor.sh &> /dev/null