iNotify how to detect move-out
You need to check for the IN_MOVED_FROM
event and a following IN_MOVED_TO
event. If the cookie is the same, the file has been renamed in the same folder. If you don't receive a IN_MOVED_TO
event with the same cookie, the file has been moved outside of the watched folder.
Monitor Directory for Changes
Look at inotify.
With inotify you can watch a directory for file creation.
monitoring and searching a file with inotify, and command line tools
monitor mode (-m)
of inotifywait
may serve better here :
inotifywait -m -q -e create -e modify -e close log_directory |\
while read -r dir action file; do
...
done
monitor mode (-m)
does not buffer, it just print all events to standard output.
To preserve the variables :
while read -r dir action file; do
echo $dir $action $file
done < <(inotifywait -m -q -e create -e modify -e close log_directory)
echo "End of script"
Related Topics
Socket Programming Send() Return Value
How to Prevent Remote Branch Deletion in Git Without Using Gitolite
How to Distribute C++11 Shared Library on Centos6
Sed Command Works on Linux, But Not on Os X
See What Process Last Touched a File
Does Gcc Support Command Files
Generating a Comprehensive Callgraph Using Gcc & Egypt
Qt Does Not Create Output Files in Debug/Release Folders in Linux
Linux Shell Kill Signal Sigkill && Kill
Why 'Read' Command in Shell Script Is Missing Initial Characters
Tail Logback Log Files with Log Level Coloring in Linux Server
Error: You Must Install at Least One Postgresql-Client-<Version> Package
How to Change Qmake Prefix Location