views:

534

answers:

1

Im trying to use inotifywait to detect every time a file or folder gets moved into a folder in realtime (eg. /root in the case)

I tried this, which does detect both folders and files, but this is for a created file, I want it for a moved file/folder.

inotifywait --monitor --format %f --event create /root

So then I use this, but using this only sees when a folder is moved in, when I move in a file nothing is shown... :(

inotifywait --monitor --format %f --event moved_to /root

Any idea what's going on?

PS, Im using Linux, Debian 5 (Lenny).

+1  A: 

You can specify many events with inotify. In your case it seems you need something like :

inotifywait --monitor --format %f --event move --event create /root

It should works. If you need more, read carefully the man page :

  -e <event>, --event <event>
        Listen for specific event(s) only. 
        The events which can be listened for are listed in the EVENTS section.
        This option can be specified more than once.  
        If omitted, all events are listened for.

[...]

EVENTS
       The following events are valid for use with the -e option:

[...]
       move   A  file  or  directory  was moved from or to a watched directory.  
       Note that this is actually implemented simply by listening for both moved_to
       and moved_from, hence all close events received will be output as one or both
       of these, not MOVE.

       create A file or directory was created within a watched directory.

It works for me with move / touch. Hope it helps ...

neuro