shell监控文件变动后执行自定义命令

Saturday, Oct 16, 2021 | 1 minute read | Updated at Saturday, Oct 16, 2021

@

shell监控文件变动后执行自定义命令

主要是监测指定文件夹内的变动,比如修改,删除,创建等等

apt-get install inotify-tools -y

 #!/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

搞定了就这么简单!记得赋予脚步执行权限!

© 2018 - 2026 vpslala

🌱 Powered by Hugo with theme Dream.