4

I am trying to make a script to monitor a directory of the EC2 webserver I am managing. I found inotify and tried to make the following script but upon trying it nothing happened.

#!/bin/sh

while inotifywait --monitor --recursive --event create --event delete /var/www/usrfiles; do

    echo "Files on the server have changed." | mail -s "server change" [email protected]

done

http://linux.die.net/man/1/inotifywait

1
  • Just as a reference making the following changes made this runnable but like EEAA said better ways are to be found. while :; inotifywait (no --monitor) [options]; do; -- email; -- done
    – mrhobbeys
    Commented Mar 8, 2013 at 0:58

1 Answer 1

2

You want incron. It takes care of this sort of thing in a much easier, more reliable fashion than trying to hack things together yourself.

http://inotify.aiken.cz/?section=incron&page=about&lang=en

1
  • I am marking this answered because I used this for a while with success before altering the entire implementation. This, incron, works very well.
    – mrhobbeys
    Commented May 7, 2013 at 21:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .