i have a short script in bash, which need to run as daemon on background. It's based on inotifywait, which should wait for changes on specified folder and in case of any changes it should runs copy process.
#! /bin/sh
case "$1" in
start)
dir=/var/www/www/source/
target=/var/www/www/htdocs/application/cache/target/
inotifywait -m "$dir" --format '%w%f' -e close_write |
while read file; do
cp "$file" "$target"
done
;;
stop)
;;
esac
i already placed it to /etc/init.d, after save run update-rc.d myscript defaults, but now, when i try start it throw service start command it stop stucked on messages from inotifywait.
/etc/init.d/bash start
Setting up watches.
Watches established.
Can you please give me some hint how to run it in background process withouth any output messages (in ideal way immediately after startup)?