如题.
离线
试一试 inotifywait 命令。
离线
试一试 inotifywait 命令。
谢谢啊, 这个不错, 试了一下
https://unix.stackexchange.com/questions/24952/script-to-monitor-folder-for-new-files
$ inotifywait -m /tmp -e create -e moved_to
Setting up watches.
Watches established.
/tmp/ CREATE sh-thd.HxgPGz
/tmp/ CREATE aaaa
/tmp/ CREATE,ISDIR ccc
现在正在找怎么获取新增文件的全路径。
离线
递归监测 /tmp 目录变化:
inotifywait --recursive -m /tmp -e create -e moved_to |
while read dir action file; do
echo "The file '$file' appeared in directory '$dir' via '$action'"
# do something with the file
done
$ inotifywait --recursive -m /tmp -e create -e moved_to |
> while read dir action file; do
> echo "The file '$file' appeared in directory '$dir' via '$action'"
> # do something with the file
> done
Setting up watches. Beware: since -r was given, this may take a while!
Watches established.
The file 'aaaanb' appeared in directory '/tmp/ccc/ddd/ee/ff/g/' via 'CREATE'
The file 'sh-thd.mdd8J1' appeared in directory '/tmp/' via 'CREATE'
The file 'sh-thd.WX0x9Z' appeared in directory '/tmp/' via 'CREATE'
The file '555' appeared in directory '/tmp/ccc/ddd/ee/ff/' via 'CREATE'
离线