【问题标题】:Inotify compatible Shell script to monitor shell a certain directoryInotify 兼容的Shell 脚本监控shell 某个目录
【发布时间】:2012-07-29 05:43:21
【问题描述】:

这是堆栈溢出中的第一个问题。需要一个 inotify 兼容的脚本编写来监视某个目录,如果在其中创建了任何新文件/文件夹,请将这些文件复制到另一个文件夹。我需要脚本不断监视更改而不是定期运行。 提前谢谢。

【问题讨论】:

    标签: linux shell monitor inotify


    【解决方案1】:

    您可以使用inotify-tools 页面中的inotifywait 来构建类似的东西。典型用法:

    inotifywait -m /tmp | while read path events name; do
      echo "Now I am going to do something with $name in directory $path."
    done
    

    有很多选项可以控制inotifywait 的操作方式;有关详细信息,请参阅手册页。

    【讨论】:

    • 谢谢..你能告诉我如何完成我问的任务的逻辑吗?另外,你能推荐我一些关于inotify的好教程吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-04-16
    • 1970-01-01
    • 2011-11-04
    • 2012-04-11
    • 2013-12-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多