# Watch directory for changes

Watching directory for changes can be useful for example let's say you have a markdown based knowledgebase and want to automagically rebuild statically served html-site. Like this one right here!

## Script

Use #bash and make a fancy scriptie using `inotify-tools`. This can be installed from debian repos using `sudo apt install inotify-tools`. For example this #mkdocs site uses following at the time of writing:

``` sh
#!/bin/sh
. bin/activate
while true
do
    mkdocs build
    inotifywait -r dokut
done
```
Main takes here are the infinite loop that rebuilds docs and then waits for any change in directory (recursively) before looping again. Here would also be a good place to setup some `sleep`ing to ratelimit things or a more complex script to even wait no more changes are detected for some time...