1

inotifwait 不会运行命令

输出“设置手表。建立手表”,脚本退出

 #!/bin/bash

while $(inotifywait -e  modify,close_write /home/centos/test.txt);
do
  touch /home/centos/log.txt
done

但是当我修改 test.txt log.txt 时没有创建

试过这个版本:

#!/bin/bash

inotifywait -e modify,close_write /home/centos/test.txt |
while read output; do
  touch /home/centos/log.txt;
done

也试过这个:

inotifywait -e modify,close_write /home/centos/test.txt |
while read -r filename event; do
  echo "test"        # or "./$filename"
done
4

1 回答 1

2

通过添加解决它-m /folder

于 2018-10-03T09:32:21.930 回答