2010-07-06 66 views

回答

10

Linux的子系统调用inotify可能导致文件系统将文件系统中的更改报告给应用程序。

你的linux系统可能有一个叫incron的软件包,这使得使用inotify非常容易。 (或者搜索您的可用软件包,查找其描述中包含单词'inotify'的任何软件包)。

设置incron很像设立cron,除了而cron在指定的时间和日期执行一个脚本,incron执行脚本每当一个指定的文件或目录的变化。

PS。在Ubuntu(例如),incronthis package,安装了

sudo apt-get install incron 
0

我试图做同样的事情,最后写一个python脚本来为我做。

https://github.com/bawigga/spy

用法:

$ ./spy myscript.py 
... your script output ... 

$ ./spy --help 
Usage: spy [OPTIONS] [WATCH] 

Options: 
    --version    show program's version number and exit 
    -h, --help   show this help message and exit 
    -c, --clear   clear the screen after each execution 
    -e COMMAND, --exec=COMMAND 
         path to the program to execute 
    -i INTERVAL, --interval=INTERVAL 
         (in seconds) set the time interval to check for file 
         modifications 
相关问题