I want to automatically run a script whenever new files are copied into a particular directory. In other words, is there a way in Linux to "watch" a directory for changes and then run something in response to the change?
Linux – How to automatically run a script when the contents of a directory changes in Linux
inotifylinuxscripting
Related Topic
- Linux – File audit in Linux: how to watch directory tree for deletions
- How to trigger a script to run after the rsyncdaemon received file changes to a certain folder
- Linux – How to re-order windows, change the scroll shortcut, and modify the status bar contents in GNU Screen
- Linux – How to run a command multiple times, using bash shell
- Linux Web Server – Proper Permissions for Website Files and Folders
Best Answer
If you're lucky enough to be on a debian-based distribution,
apt-get install dnotify
. Other distributions probably have something similar - look for thednotify
name.If you want to handle this within your own program, dnotify is also the API you want to use.