start-stop-daemon on an inotify script
Hi all,
(cross-post from here:
http://superuser.com/questions/571416/start-stop-daemon-on-an-inotify-scripti)
I am on debian squeeze.
Consider this stripped down script (placed at
/usr/local/bin/testinotify) around inotifywait:
#+begin_src sh
#!/bin/bash
WATCHDIR="/tmp/testinotify"
inotifywait -mr --timefmt '%d/%m/%y %H:%M' --format '%T %w %f' \
-e modify -e create -e close_write \
"$WATCHDIR" | while read date time dir file; do
FILECHANGE=${dir}${file}
chgrp users "$FILECHANGE"
chmod g+rw "$FILECHANGE"
if [ -d "$FILECHANGE" ]; then
chmod g+x "$FILECHANGE"
fi
echo "At ${time} on ${date}, file $FILECHANGE was chmodded" >> "$1"
done
#+end_src
If I run this "by hand" via
testinotify /var/log/testinotify.log
everything works as expected.
Here is my question: If I run this via start-stop-daemon as in
PIDFILE=/var/run/testinotify.pid && DAEMON=/usr/local/bin/testinotify && LOGFILE=/var/log/testinotify.log && start-stop-daemon --start --quiet --oknodo --pidfile "$PIDFILE" --make-pidfile --startas "$DAEMON" -- $LOGFILE &
I get two instances of my script running.
Why is that and how can I avoid that?
The bad effect is, that killing the process with pid recorded by
start-stop-script is not even stopping the inotifywait.
Regards,
Andreas
Reply to: