简体   繁体   English

用 incron 监视文件夹似乎会杀死我的服务器

[英]Watching folder with incron seems to kill my server

I would like to run a php script on a folder whenever content in that folder changes (a file is edited, or overwritten, or added or deleted).每当文件夹中的内容发生更改(文件被编辑、覆盖、添加或删除)时,我想在文件夹上运行 php 脚本。

The php script gets a hash code for each file in the folder, and writes all the lines in a hash.txt file (appending a line like hashcode:filename for each file, eg 2dbb8badb0925833c8ea03ffc941e3a0:file1_blabla.utf8 ). The php script gets a hash code for each file in the folder, and writes all the lines in a hash.txt file (appending a line like hashcode:filename for each file, eg 2dbb8badb0925833c8ea03ffc941e3a0:file1_blabla.utf8 ).

After adding my user to /etc/incron.allow , I have edited my icrontab -e in the server, and added the following line:将我的用户添加到/etc/incron.allow后,我在服务器中编辑了我的icrontab -e ,并添加了以下行:

/var/www/mydir/tests/ IN_ALL_EVENTS php -f /var/www/mydir/tests/mk_hash_list.php

The result: some kind of killer loop that collapse my server with an ever growing log, which shows lines like:结果:某种杀手循环使我的服务器崩溃,日志不断增长,显示如下:

Jun 24 19:24:30 myserver incrond[22010]: (manuel) CMD (php -f /var/www/mydir/tests/hash_list.php)
Jun 24 19:24:30 myserver incrond[22010]: cannot fork process: Resource temporarily unavailable

Any tips?有小费吗? Is icrontab good for what I'm trying to do? icrontab 对我想做的事情有好处吗? Thanks.谢谢。

The file to which the script appended data was written in the watched folder, creating an endless loop.脚本附加数据的文件被写入监视文件夹中,从而创建了一个无限循环。 The solution was to create a subfolder containing only the files that the script should analyze and keep both the script and the written file with the result outside of that watched subfolder.解决方案是创建一个子文件夹,其中仅包含脚本应分析的文件,并将脚本和写入的文件与结果一起保存在该监视的子文件夹之外。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM