I made a slightly more complex shell script and posted it in an article :
inotifywait -mr source --exclude _build -e close_write -e create -e delete -e move --format '%w %e %T' --timefmt '%H%M%S' | while read file event tm; do current=$(date +'%H%M%S') delta='expr $current - $tm' if [ $delta -lt 2 -a $delta -gt -2 ] ; then sleep 1
This makes the inotifywait not only the file name and action, but also the inotifywait time. The script compares the timestamp with the current unixtime time, and if the delta is less than 2 seconds, it runs make html . But before that, he sleeps 1 second to complete file operations. For the following modified files, the timestamp will be old, the delta will be more than 2 seconds, and nothing will be done.
I found that this method consumes the least processor resources and is the most reliable.
I also tried to run a simple Python script, but that meant that if I inserted something as big as jQueryUI into the folder, thousands of processes were started and then turned into zombies.
source share