
shell监控文件变动后执行自定义命令
shell监控文件变动后执行自定义命令
主要是监测指定文件夹内的变动,比如修改,删除,创建等等
apt-get install inotify-tools -y
1
2
3
4
5
6
7
#!/bin/bash
DIR=/var/www/dmoain/
inotifywait -m -e close_write $DIR --format "%w%f" | while read FILE
do
cat ${FILE} | /usr/bin/supervisorctl update && /usr/bin/supervisorctl reload
done
搞定了就这么简单!记得赋予脚步执行权限!