我想在新文件复制到特定目录时自动运行脚本.换句话说,Linux中是否有一种方法可以“监视”目录以进行更改,然后运行某些内容以响应更改?
解决方法
如果你很幸运能够使用基于debian的发行版,那么apt-get install会进行dnotify.其他发行版可能有类似的东西 – 寻找dnotify名称.
dnotify is a simple program based on Linux kernel 2.4.19+’s dnotify API.
dnotify can execute a specified command each time the content of a specific
directory changes. It is run from the command line and takes two arguments:
one or more directories to monitor and a command to execute whenever a
directory has changed. Options control what events to trigger on: when a file
was read in the directory,when one was created,deleted and so on.
如果您想在自己的程序中处理此问题,则dnotify也是您要使用的API.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。