Make your own web page change monitor by using the recipe sketched below:

Call the following file “webmon”:

#!/bin/sh

ARGS=2 # Two args to script expected.
E_BADARGS=65
E_UNREADABLE=66

date > /tmp/webmon_last_run.log

if [ $# -ne “$ARGS” ]
then
echo “Usage: `basename $0` webmonname url”
exit $E_BADARGS
fi
wget -q -O – $2 | md5 > /tmp/temp.md5

if [ -r /home/user/scripts/webmon/$1.md5 ]; then
cmp /tmp/temp.md5 /home/user/scripts/webmon/$1.md5 > /dev/null
if [ $? -eq 1 ]; then
date >> /home/user/Desktop/webmon.txt
echo “The site \”$1\” has been updated.” >> /home/user/Desktop/webmon.txt
echo “$2” >> /home/user/Desktop/webmon.txt
echo ” ” >> /home/user/Desktop/webmon.txt
fi
fi
cp /tmp/temp.md5 /home/user/scripts/webmon/$1.md5

Then write a batch file called “batch”:

#!/bin/sh
date > /tmp/webmonbatch_last_run.log

/home/user/scripts/webmon/webmon cnnmainpage http://edition.cnn.com/index.html
/home/user/scripts/webmon/webmon nytimesfront http://www.nytimes.com/index.html

Lastly, create a cron-job using crontab -e to execute the batch-job:

*/1 * * * * /home/user/scripts/webmon/webmon

Advertisements