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



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

正如评论中所建议的,我建议您安装 inotify:

sudo apt-get install inotify-tools

之后,您可以执行以下简单操作:

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

您可以阅读手册页以获取inotifywait了解更多信息。

相关内容

最新更新