Post Reply 
Feature Request: Re-Scan/inotify
30-04-2012, 14:55
Post: #12
RE: Feature Request: Re-Scan/inotify
i have created the following bash script to automatically restart my minim instance when files are added/deleted/modified:
Code:
#!/bin/sh
LOCK_FILE=/opt/minim/inotify.lck

restartminim() {
        while true; do
                if [ -e "$LOCK_FILE" ] ; then
                        if test `find "$LOCK_FILE" -mmin +1`
                        then
                                /opt/minim/restartminim.exp
                                rm $LOCK_FILE
                        fi
                fi
                sleep 60
        done
}

myinotifywait() {
        while inotifywait -q -r -e close_write,move,delete /media/upnp/Musik/; do
                touch $LOCK_FILE
        done
}

myinotifywait&
pid1=$!
echo "Myinotifywait spawned: $pid1"

restartminim&
pid2=$!
echo "Restartminim spawned: $pid2"

# Kill all sub-processes
trap "kill 0" SIGINT SIGTERM EXIT
wait

echo "finish."
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Feature Request: Re-Scan/inotify - KoS - 30-04-2012 14:55

Forum Jump:


User(s) browsing this thread: 1 Guest(s)