我在 CentOS 7 上使用inotify-tools 在每次 ftp 上传时执行一个 php 脚本。
它工作正常,但有一个问题;当上传中止时(例如,如果我停止上传或关闭 FTP 客户端),它仍然会触发脚本。
这可以避免这些情况吗?
我的代码:
#!/bin/sh
MONITORDIR="/path/to/some/dir"
inotifywait -m -r -e close_write --format '%w%f' "${MONITORDIR}" | while read NEWFILE
do
php /path/to/myscript.php ${NEWFILE}
done