简体   繁体   English

incrond不执行python脚本

[英]incrond doesn't execute python script

I need to run a python script on every file, that is written into a specific folder. 我需要在每个写入特定文件夹的文件上运行python脚本。 So I created a file in /etc/incron.d/ and added the following line: 因此,我在/etc/incron.d/中创建了一个文件,并添加了以下行:

/srv/ftp IN_CREATE /usr/bin/python3 /srv/parser.py $@/$# >> /var/log/parser/incron.log 2>&1

the syslog shows me: syslog向我显示:

incrond[32630]: (system::parser) CMD (/usr/bin/python3 /srv/parser.py /srv/ftp/00008260_2015-12-09T17-31-36.csv >> /var/log/parser/incron.log 2>&1)

but the log is empty, and the script did not do anything 但是日志为空,脚本没有执行任何操作

I found the problem: IN_CREATE fires even if the file is not completely written, because of this, it works on when copying is extremely fast, like cp a 10kb file from one folder to another, but definitely not over FTP, the correct event is IN_CLOSE_WRITE, it will fire after the ftp server does a fclose(), and secondly inconrd does not like more than one command 我发现了问题:即使文件未完全写入,也会触发IN_CREATE,因此,当复制速度非常快时(例如从一个文件夹到另一个文件夹cp一个10kb的文件cp,但绝对不是通过FTP进行cp传输),它会起作用IN_CLOSE_WRITE,它将在ftp服务器执行fclose()之后触发,其次inconrd不喜欢多个命令

so the following works: 所以以下工作:

/srv/ftp IN_CLOSE_WRITE /srv/parser.py $@/$#

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

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