我在 CentOS 7 上使用inotify-tools ( inotifywait
) 在每个文件创建时执行一个 php 脚本。
当我运行以下脚本时:
#!/bin/sh
MONITORDIR="/path/to/some/dir"
inotifywait -m -r -e create --format '%w%f' "${MONITORDIR}" | while read NEWFILE
do
php /path/to/myscript.php ${NEWFILE}
done
我可以看到有2个过程:
# ps -x | grep mybash.sh
27723 pts/4 S+ 0:00 /bin/sh /path/to/mybash.sh
27725 pts/4 S+ 0:00 /bin/sh /path/to/mybash.sh
28031 pts/3 S+ 0:00 grep --color=auto mybash.sh
为什么会这样,我该如何解决?