lsyncd auto synchronize file

add epel repos

yum install lsyncd

add /etc/init.d/lsyncd

#!/bin/bash
#
# lsyncd: Starts the lsync Daemon
#
# chkconfig: 345 99 90
# description:  Lsyncd uses rsync to synchronize local directories with a remote
# machine running rsyncd. Lsyncd watches multiple directories
# trees through inotify. The first step after adding the watches
# is to, rsync all directories with the remote host, and then sync
# single file buy collecting the inotify events.
# processname: lsyncd

. /etc/rc.d/init.d/functions

lsyncd="/usr/bin/lsyncd"
configfile="/etc/lsyncd.conf"
lockfile="/var/lock/subsys/lsyncd"
pidfile="/var/run/lsyncd.pid"
prog="lsyncd"

RETVAL=0
start()
{
  if [ -f $lockfile ]; then
      echo -n $"$prog is already running: "
  else
      echo -n $"Starting $prog: "
      daemon "$lsyncd  $configfile & >/dev/null"
      echo

      RETVAL=$?

      [ -f $pidfile ]  && touch $lockfile

      return $RETVAL
  fi
}
stop()
{
   echo -n $"Stopping $prog: "
   killproc $lsyncd
   RETVAL=$?
   echo
   [ $RETVAL = 0 ] && rm -f $lockfile
   return $RETVAL
  fi
}
stop()
{
   echo -n $"Stopping $prog: "
   killproc $lsyncd
   RETVAL=$?
   echo
   [ $RETVAL = 0 ] && rm -f $lockfile
   return $RETVAL
}

case "$1" in
   start)
     start
    ;;
   stop)
     stop
    ;;
   restart)
     stop
     start
    ;;
   status)
     status $lsyncd
    ;;
   *)
     echo "Usage: lsyncd {start|stop|restart|status}"
     exit 1
esac

exit $?

add service

# chkconfig --add lsyncd
# chkconfig lsyncd on

add configure file

-- /etc/lsyncd.conf
syncpass={
 maxProcess=10,
 delay=0,
 onModify="/pkg/pdsh/2.26/bin/pdcp -r -wnode[1-67] ^sourcePathname ^targetPathname "
}
settings = {
 logfile = "/var/log/lsyncd.log",
 statusFile = "/var/lib/lsyncd.status",
 nodaemon = true,
}
sync {
 syncpass,
 source = "/etc/syncpass",
 target = "/etc",
}