I have a local directory of media files on a Linux system that I sync with my Amazon S3 account using s3sync script. Currently, I manually run the s3sync script when I know that the media files have been modified.
How can I automatically run a script when changing files?
I was thinking of creating a cron job to run the script every few minutes, but this seems like over processing, because even if there are no changes, the script will still have to scan the entire directory structure, which is quite large.
I also considered incron / inotify , which allows you to run commands when a specific file or directory is changed, but these tools do not seem to automatically support monitoring changes in the entire subdirectory. Correct me if I am wrong, but it seems that incron / inotify can only track files that they clearly need to track. for example, if I wanted to track changes to all files at any level within a directory, I would have to write separate scripts to track changes and deletions of directory files and files to update the list of files and directories controlled by incron.
Are there more effective solutions?
Cerin
source share