我正在调查定时任务并尝试如下:
/tmp/incron.sh:
echo "$1 Content: `cat /tmp/test/a`" >> /tmp/incron.log
incrontab -l
:
/tmp/test/a IN_CLOSE_WRITE /tmp/incron.sh write
/tmp/test/ IN_CREATE /tmp/incron.sh create
我创建/tmp/test/a
并保存了文件,日志中显示以下内容:
create Content:
create Content:
create Content:
create Content: test
write Content:
我想我明白为什么日志中没有条目 - 因为守护进程加载表时该文件不存在
编辑文件后,日志如下所示:
create Content:
create Content:
create Content:
create Content: test
create Content: test
create Content: test
create Content: test
create Content: test 2
create Content: test 2
然后我重新启动了守护进程(sudo service incron restart
)并再次编辑了该文件。现在日志如下所示:
create Content:
create Content:
create Content:
create Content: test
create Content: test
create Content: test
create Content: test
create Content: test 2
create Content: test 2
create Content: test 2
create Content: test 2
create Content: test 2
create Content: test 3
create Content: test 3
write Content: test 3
有人能解释一下这里发生了什么吗?