1
1
I want to have my server send me an email every time someone accesses a PDF file on my webserver.
Perhaps:
tail -f /var/log/apache.log | grep pdf > ??something??
How would I generate a new email message each time this tail/grep outputs something? How could I have that running as a background script?
Thanks. For now I got the following sh script working. It fits in my current experience level. I may try inotifywait later.`#!/bin/bash FILE=/var/log/apache2/access.log TERM="pdf"
while read line; do echo $line | grep $TERM > /dev/null && echo $line | mail -s "new $TERM access" something@gmail.com done < <(tail -1f $FILE)` – Rob Reid – 2014-02-12T18:02:03.620