Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是堆栈溢出中的第一个问题。需要一个 inotify 兼容的脚本编写来监视某个目录,如果在其中创建了任何新文件/文件夹,请将这些文件复制到另一个文件夹。我需要脚本来不断监控变化,而不是定期运行。提前谢谢。
您可以inotifywait从inotify-tools页面中使用 来构建类似的东西。一个典型的用途:
inotifywait
inotify-tools
inotifywait -m /tmp | while read path events name; do echo "Now I am going to do something with $name in directory $path." done
有很多选项可以控制inotifywait操作方式;有关详细信息,请参阅手册页。