我需要编写一个 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
了解更多信息。