Web based file watcher

We needed to check a file was being written to a remote server at least every 15 minutes or so. This bash script, run as a cron job, uses curl to get the HTTP headers and then sed to extract “Last Modified” time. The actual log file is not downloaded.

#!/bin/bash
START=$(/bin/date +%s)
LASTMOD=` /usr/bin/curl -Is http://www.example.com/logs/log.txt | /bin/sed -n 's/^Last-Modified: *\([^ ]*\) */\1/p' `
LASTTIME=$(/bin/date +%s -d "$LASTMOD")
DIFF=$(($START - $LASTTIME ))
if [ "$DIFF" -gt "900" ]
then
MAIL_TXT="Subject: Log file not updating\nFrom: info@example.com\nTo: info@example.com\n\nAge is $DIFF"
echo -e $MAIL_TXT | /usr/sbin/sendmail -t
fi

Cron entry is

*/15 * * * * /home/robin/checkweblastmod.sh

Bluelighthost, iCloud or BBS Commerce Ltd

Bluelighthost are doing a free 7 day trial (http://www.bluelighthost.com/our-services). It look great so I gave it a spin. 1/2 day later I had Ubuntu, Nginx, MySQL running a WordPress mu. Brilliant! You get a medium VM for £15 ex vat so, after checking my vm would stay alive I signed up. Next day my vm was gone :-( Apparently I didn’t choose an upgrade. They couldn’t restore it and I got passed from pillar to post (the number on the support ticket was iCloud not Bluelighthost). When I eventually got through to Bluelighthost they told me to send an email! They did answer the email quickly but by that time I had restored an image of my server to a home machine and was slightly annoyed. They refunded my money without question.

Conclusion: Probably a good service but some organisational teething problems. Always keep backups and triple check when upgrading that your vps will survive.