2
我跑作爲守護聽文件的腳本:如何在Bash中運行多個inotifywait循環?
#!/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;
我想聽聽幾個文件,並試圖增加了兩個循環:
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;
我意識到第一循環永遠不會關閉,所以其他的永遠不會開始,但不知道我應該如何解決這個問題。
?你是否期望文件重新打開並關閉多次,每次關閉時都調用'curl'? – chepner