+ -
当前位置:首页 → 问答吧 → 如何监控某个文件夹下的变化

如何监控某个文件夹下的变化

时间:2010-07-24

来源:互联网

HP-UX (Linux)下如何监控某个文件夹下的变化?

指的是,该文件夹下新增了文件。

用什么可以实现? 用Perl可以吗? 用ANSI C可以吗?

作者: cups_book   发布时间: 2010-07-24

当该文件夹下有新文件夹时,把新的文件夹内的数据读入数据库

作者: cups_book   发布时间: 2010-07-24

据我所知,hp-unix没有提供文件访问事件触发的机制。你去轮询吧。

作者: caravsapm70   发布时间: 2010-07-24

回复 caravsapm70


    文件访问事件触发的机制?

    我的想法是用一个程序,每隔一分钟,查看一下这个文件夹,这是不是你说的轮询?

    用什么程序呢?

作者: cups_book   发布时间: 2010-07-24

linux下有inotify,可以监控目录文件,事件触发。
hp-unix就是你说的那样子了,我们管它叫轮询。

作者: caravsapm70   发布时间: 2010-07-24

本帖最后由 cups_book 于 2010-07-24 01:09 编辑

回复 caravsapm70


   
嗯,我在看。
http://linux.die.net/man/7/inotify

The inotify API provides a mechanism for monitoring file system events.
Inotify can be used to monitor individual files, or to monitor directories.
When a directory is monitored, inotify will return events for the directory itself, and for files inside the directory.

The following system calls are used with this API: inotify_init(), inotify_add_watch(), inotify_rm_watch(), read(), and close().

杯具的是, 我还是不知道怎么用。。。。

作者: cups_book   发布时间: 2010-07-24