Introducing how to monitor and watch file changes using the Bash command inotifywait in the Linux command line language Bash, and execute arbitrary commands when changes occur.
In the following example, hoge is output to standard output when “$PWD/_config.yml” is changed. (I tried to do this with jekyll on docker but couldn’t. It’s a so-called known issue.)
while inotifywait -o ~/inotifywait.log --quiet --timefmt "%a, %d %b %Y %T %z" --format "%T %f%w %e" "$PWD/_config.yml"; do echo hoge ; done
Reference: linux - How to execute a command whenever a file changes? - Super User