1,安装inotify
apt-get update && apt-get install -y inotify-tools
2,监控脚本reload-watch.sh
DIRECTORY="/nginx/conf/conf.d/"
inotifywait -mrq -e create,modify,move,delete --timefmt '%Y-%m-%d %H:%M:%S' --format '%T %w%f %e' $DIRECTORY |
while read fdate ftime file event; do
echo "$fdate $ftime - File $file was $event, reload nginx conf..."
nginx -s reload
done