简体   繁体   中英

incrond doesn't execute python script

I need to run a python script on every file, that is written into a specific folder. So I created a file in /etc/incron.d/ and added the following line:

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

the syslog shows me:

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

so the following works:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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