Monitoring a log file and send a notification (mail) when string is triggered

  • I want a nofitication (email) when the userfoobar is triggerd in the apache log like this


    Quote

    10.10.55.171 - userfoobar [21/Nov/2014:12:06:01 +0100] "GET /download/2719/test.jpg HTTP/1.1" 200 199164336 "-" "Mozilla/5.0
    (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"


    Code
    1. tail -f /apache/userfoobar/access.log | grep user-foobar | mailx [email protected]


    is there any easy solution (perl, bash) that considered the log rotation?


    I spend 5 Euro to i-MSCP for a working solution.