How to determine if any file in a directory has changed

喜欢而已 提交于 2019-12-02 04:34:18

Chef provides a concept called notifications.

This allows you to define that a change in one resource triggers execution of another resource. The mentioned restart of a service after the config file changed is probably the most common use case.

template "/etc/foo/conf.d/example.conf" do
    notifies :restart, "service[foo]"
end

service "foo" do
    supports :restart => true, :reload => true
    action :enable
end

By default, notifications are :delayed, which means that they are triggered at the end of the Chef run. This helps you to avoid e.g. a service to restart once for every single changed configuration file. If you want an immediate notification, use

notifies :restart, "service[foo]", :immediately

Of course, you can use Chef's notifications not only for services, but for any resource. More examples are given in the documentation.

You can use inotifywait utility from the inotify-tools package

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!