watchdir - watch for changes in a directory tree
watchdir [OPTION] DIRECTORY
watchdir monitors the given DIRECTORY and all its subdirectories for changes. At regular intervals, the names of the files and directories which have changed are written to a uniquely named file in the OUTPUTDIR directory:
Changes to directories are treated in the same way:
All paths are given relative to the top-level DIRECTORY. Directory names always end in /, which means that just / on its own in a change file means that the top-level directory itself changed (i.e. a file or directory was removed from it).
The change files in OUTPUTDIR are given names of the form YYYYMMDD-hhmmss.pid where YYYY is the 4-digit year, MM is the 2-digit month, DD is the 2-digit day of the month, hh, mm, ss are 2-digit hours, minutes, and seconds in the 24-hour clock, and pid is the process ID of watchdir.
Note that OUTPUTDIR must not be a subdirectory of DIRECTORY.
This option can be specified multiple times.
The default is to exclude *.tmp and *~.
If you watch a lot of directories, you will probably need to increase the kernel parameter fs.inotify.max_user_watches, for example:
sysctl -w fs.inotify.max_user_watches=1048576
You may also need to increase fs.inotify.max_user_instances.
The change files can be used directly as input to rsync(1)'s --files-from option, like this:
rsync --delete -dlptgoDH --files-from=OUTPUTDIR/20140731-112501.1234 DIRECTORY remote:/dir/copy/
A similar command line is used by continual-sync(1) when doing a partial sync.
Changes to file permissions are not listed - only changes which alter the contents of a file or its last-modification time.
When watching a directory with a large number of subdirectories, it may take watchdir(1) an inconveniently long time to finish scanning through them all and begin watching for changes.
Report bugs in continual-sync to email@example.com or use the contact form linked from the package home page: <http://www.ivarch.com/programs/continual-sync.shtml>
continual-sync(1), rsync(1), glob(7), lsyncd(1), rsync-inotify(1), inosync(1)
This is free software, distributed under the ARTISTIC 2.0 license.