我想在脚本中检测到配置更改时使用inotifywait重新启动nginx。问题是,如果我以守护进程模式运行它,它会继续重新启动nginx。使用inotifywait进行nginx重启
脚本是这样的:
while inotifywait -d -o /var/log/bootstrap.log --format '%T %:e %w' --timefmt '%Y.%m.%d %H:%M:%S' -e modify,create,delete,move,attrib $(find -L /etc/nginx -type f)
do
NGX_STATUS=$(nginx -t 2>&1)
NGX_CFG_STATUS=$(echo $NGX_STATUS | grep successful)
if [[ $(echo $?) == 0 ]]; then
/etc/init.d/nginx restart
else
echo $NGX_STATUS | tee -a /var/log/bootstrap.log
fi
done
注:此脚本是泊坞窗入口点脚本的一部分。
'/ var/log/bootstrap.log'中有什么? – Tim
grep:警告:不推荐使用GREP_OPTIONS;请使用别名或脚本 *重新启动nginx nginx – zozo6015