Shell script to email when web page has updates/changed

Some shipping companies don’t have any sort of notification system for when updates happen to packages. For small things, this is probably not a major issue, but when i ordered my huge Patio roof, i needed to be at home when it was being delivered to help unload.

Unfortunately the website did not have any notifications, and the alternative was to hit reload on the page all the time to check. I figured this should be easy to script and so wrote this small shell script to watch the page, and email me if there were any updates


# URL to check
# Temp file to store the tracking page
# Get the page, remove dynamic content of newrelic and diff feedback on that
modified=$(wget -q -O $temp $url ; diff ${temp} ${temp}.1 |grep -v newrelic |grep -v --  "--" |grep -v 8c8 )
# This is a good idea if it has the Last Modified headers, but in my case it didn't
#modified=$(curl -sI "$url" | grep ^Last-Modified)
# set email address
# Check if the modified variable exists and is more than 0 characters
if [[ ! -z "$modified" && ${#modified} -gt 0 ]]; then
    # Email me the changes if there are any
    echo $url has changed  $modified  - modified| mail -s "Tracking Update"  ${email}
    # Copy the recent grab of the page to the second file to compare to next time
    cp ${temp} ${temp}.1

The initial idea was to check for Last-Modified headers, but they did not have those, so i ended up dumping the page to /tmp/trackingcheck and comparing against /tmp/trackingcheck.1 . I had to adapt my diff command to remove the newrelic dynamic content lines, which probably could have been done, but over all the script worked nicely.
I set up a cron task to run that every 10 minutes. If the page has changed, it emails me, and copies the temp file to /tmp/trackingcheck.1

*/10 * * * * /home/velofille/