如何在将任何文件或文件夹复制/移动到目录时检测并运行shell脚本?

如何检测正在复制/移动到目录的任何文件或文件夹,然后运行shell脚本?

复制/移动的文件通常与现有文件具有相同的文件名…

您应该使用inotify-tools包中提供的inotify-tools命令行工具。

也应该更好的包inoticoming 。 描述:

 Description: trigger actions when files hit an incoming directory inoticoming is a daemon to watch a directory with Linux's inotify framework and trigger actions once files with specific names are placed in there. . For example it can be used to wait for .changes files uploaded into a directory and call reprepro to put them into your repository.