简体   繁体   English

需要shell脚本,当我的5个重写规则文件中检测到任何更改/修改时,将执行/etc/init.d/httpd

[英]need shell script which when detect any change/modification in my 5 rewrite rules file,will do a /etc/init.d/httpd

我需要编写一个shell脚本,当在我的5个重写规则文件中检测到任何更改/修改时,将执行/etc/init.d/httpd configtest,如果没有错误,它将重新加载apache。

As suggested in the comments I'd advise you to install inotify: 如评论中所建议,我建议您安装inotify:

sudo apt-get install inotify-tools

And after that you can do something as simple as: 然后,您可以做一些简单的事情:

while inotifywait -q -e modify filename >/dev/null; do
   echo "filename is changed"
done

You can read the manpage for inotifywait for more info. 您可以阅读inotifywait的手册页以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM