Hi!
This question isn't really Debian specific, but as I use Debian I thought
this was a good forum. I've got this small bash script that works perfectly
when I run it from the shell, but it won't work when I try to run it
through cron and I don't get any error messages from the cron daemon either
(maybe I'm looking in the wrong places).
The script below downloads the specified URL and generates and MD5 sum for
the HTML source. If this is the first time the script is run it saves the
MD5 sum in a file otherwise the MD5 sum is checked against the old one. If
they differ, the script will send an e-mail to me.
(yes, I know this script really isn't useful for slashdot as the page is
different every time...but it's good for debuging)
----------8<----------8<----------8<----------8<----------8<----------8<----------
#!/bin/bash
EMAIL="[EMAIL PROTECTED]"
MD5FILE="/home/laban/tmp/chkwww.md5"
URL="http://www.slashdot.org"
DATE=`date +"%Y-%m-%d %H:%M"`
SUBJECT="Update - $DATE"
LOG="FALSE"
LOGFILE="/home/laban/tmp/chkwww.log"
###############################################
if [ "$LOG" = "TRUE" ]; then echo -e "$DATE\t$0\tChecking for
updates..." >>$LOGFILE; fi
MD5SUM_NOW=`lynx --source $URL | md5sum`
if [ ! -e $MD5FILE ]; then
echo $MD5SUM_NOW > $MD5FILE
exit
fi
MD5SUM_DISK=`head -1 $MD5FILE`
echo $MD5SUM_NOW > $MD5FILE
if [ $MD5SUM_NOW != $MD5SUM_DISK ]; then
echo "$URL has been updated." | mail -s "$SUBJECT" $EMAIL
if [ "$LOG" = "TRUE" ]; then echo -e "$DATE\t$0\tPage updated,
notification sent to $EMAIL." >>$LOGFILE; fi
else
if [ "$LOG" = "TRUE" ]; then echo -e "$DATE\t$0\tPage not
updated." >>$LOGFILE; fi
fi
if [ "$LOG" = "TRUE" ]; then echo -e "$DATE\t$0\tExiting..." >>$LOGFILE; fi
----------8<----------8<----------8<----------8<----------8<----------8<----------
My crontab looks like this:
0,15,30,45 * * * /home/laban/bin/chkwww
Any ideas?
.//Laban - [EMAIL PROTECTED] - [EMAIL PROTECTED] - Public PGP-key available