Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #notifywait: Start/Stop inotifywait
- #
- # chkconfig: - 80 20
- # description: inotifywait waits for changes to files using inotify.
- #
- # processname: inotifywait
- #. /etc/rc.d/init.d/functions
- #. /etc/sysconfig/network
- . /etc/inotifywait.conf
- LOCK=/var/lock/subsys/inotifywait
- RETVAL=0
- start() {
- echo -n $"Starting inotifywait: "
- /usr/bin/inotifywait \
- --recursive \
- --format '%w%f %e %T' \
- --timefmt '%Y/%m/%d-%H:%M:%S' \
- --exclude '.*\.sw[pox].*' \
- -e $EVENT \
- -o $LOGFILE \
- -dmrq $MONITOR
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && touch $LOCK
- return $RETVAL
- }
- stop() {
- echo -n $"Stopping inotifywait: "
- psid=$(/bin/ps aux | /bin/grep -i inotifywait | /bin/grep -e "usr/bin" | /usr/bin/awk {'print $2'} )
- if [[ $psid > 0 ]]; then
- /bin/kill $psid
- fi
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && rm -f $LOCK
- return $RETVAL
- }
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- ;;
- status)
- /bin/ps aux | /bin/grep -i inotifywait | /bin/grep -e "usr/bin" | /usr/bin/awk {'print $2'}
- ;;
- restart)
- stop
- start
- ;;
- *)
- echo $"Usage: $0 {start|stop|status|restart}"
- exit 1
- esac
- exit $?
Add Comment
Please, Sign In to add comment