How can I run multiple inotifywait loops in Bash?

Viewed 897

I have a script that ran as a daemon listening to a file:

#!/bin/bash
echo '1'
while inotifywait -e close_write /home/homeassistant/.homeassistant/automations.yaml
do
    echo 'automations'
    curl -X POST -H "x-ha-access: pass" -H "Content-Type: application/json" http://hassbian.local:8123/api/services/automation/reload
done;

I wanted to listen to several files, and tried adding two more loops:

while inotifywait -e close_write /home/homeassistant/.homeassistant/groups.yaml
do
    echo 'gropus'
    curl -X POST -H "x-ha-access: pass" -H "Content-Type: application/json" http://hassbian.local:8123/api/services/group/reload
done;

while inotifywait -e close_write /home/homeassistant/.homeassistant/core.yaml
do
    echo 'core'
    curl -X POST -H "x-ha-access: pass" -H "Content-Type: application/json" http://hassbian.local:8123/api/services/homeassistant/reload_core_config
done;

I realized that the first loop never gets closed so the other ones never get started, but not sure how I should solve this.

1 Answers
Related