You will need to keep track of the lines already emailed. I nominated /var/log/logfile.notify. Script could be run from cron every Xmins. Note if file is truncated (eg by log rotate) the logfile.notify linecount will need to be updated, otherwise no emails till the log passes the high watermark stored in the notify file.
NOTIFY_FILE=/var/log/logfile.notify
LOGFILE=/var/log/logfile
WHO=root@localhost
LAST=0
[ -f $LOGFILE ] || exit
[ -f $NOTIFY_FILE ] && LAST=$(cat $NOTIFY_FILE)
NOW=$(wc -l $LOGFILE | cut -f1 -d' ')
if [ $LAST -lt $NOW ]
then
( if [ $LAST -gt 0 ]
then
sed "1,${LAST}d" $LOGFILE
else
cat $LOGFILE
fi ) | mailx -s "New data for $LOGFILE" $WHO
echo $NOW > $NOTIFY_FILE
fi
Funny the following code should have set LAST to zero if the notify file wasn't there. I tested this before posting. did you modify this part of the code?