inotifywait -m在长期运行过程后不会处理超过1个文件
我有一个脚本,可以检测Close_write上的文件,并在它们上运行一个约5分钟的过程。这些文件以高达100的批量写入目录。问题在于,InotifyWait仅检测批处理中的第一个文件,并且除非手工从目录中删除并放回后面,否则不会处理后续文件。这是我的脚本:
#!/bin/bash
inotifywait -r -e close_write -e moved_to --format "%f" $TARGET -m | while read file
do
if [[ "$file" =~ .*mp4$ ]]; then
echo "Detected $file"
/usr/bin/python3 LongRunningProgram.py -i $TARGET/$file -o $PROCESSED -u $UPLOADPATH -c $C
fi
done
它是由SystemCtl服务所做的:
[Unit]
Description=Description
After=network.target
[Service]
Type=idle
user=pi
WorkingDirectory=/home/pi
ExecStart=/bin/bash /home/pi/notify.sh OutPath C
Restart=on-failure
[Install]
WantedBy=multi-user.target
我很困惑为什么它似乎只能识别第一个文件,而在这样的运行时则不得识别后续文件,但是,如果我用Sleep 300替换长期运行的程序似乎效果很好。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我忽略解释“长期运行过程”的错。
InotifyWait
旋转的python脚本被称为FFMPEG进程,以在写入目录的MP4文件上进行工作。在循环中使用中的FFMPEG有一个错误。我关注此答案使用
> -nostdin
标志,并且似乎已经解决了问题。希望这个答案可以帮助其他人解决这个问题:)My fault for neglecting to explain what the "long running process" was doing. The python script that is called as a result of
inotifywait
spins up an ffmpeg process to do work on the MP4 files that were written to the directory. There is a bug with ffmpeg when using it in awhile
loop. I followed This answers solution to use the-nostdin
flag and that appears to have solved the issue. Hopefully this answer helps someone else with this problem :)