我正在尝试创建一个运行shell脚本的后台,它会注意到在filetree中创建文件时,检查文件名是否符合特定条件,通过电子邮件发送文件,然后移动它.
该应用程序 - 通过电子邮件发送FreePBX电话录音.
文件存储在/ var/spool/asterisk/monitor/yyyy/mm/dd /中
例如 - /var/spool/asterisk/monitor/2014/07/10/conf-220-220 ......
因此,当创建录制时,它会根据文件名检查其进入的位置,通过电子邮件发送并将其移出文件夹.
我看到了关于inotify-tools的建议,但网站上的最新消息是2010年.
我也看到了incron,但想要一些东西搞乱我的电话系统(我害怕安装程序)
inotify.aiken.cz/?section=incron&page=doc&lang=en
由于此版本较早,因此不包含标准的可移植构建机制(例如autotools).只有一个Makefile必须手动修改.在许多Linux系统上,您无需进行任何更改.
Tiago Lopo.. 6
inotify
正在存在一段时间,它是稳定的,并且是许多发行版主流的一部分.
如何安装:
在Ubuntu上:
sudo apt-get install inotify-tools
在Centos/RHEL上(来自EPEL回购):
yum --enablerepo epel install inotify-tools
如何使用:
inotifywait -re create /tmp/test1/ && echo "Change detected"
一旦你创建了一个文件echo "change detected"
将被触发,这可能是任何事情.
你得到的输出:
Setting up watches. Beware: since -r was given, this may take a while! Watches established. /tmp/test1/test2/test3/ CREATE file Change detected
PS.-r
用于递归-e create
检测新文件.