1.本地目录同步

# yum install lsyncd

# vi /etc/lsyncd.conf

----

-- User configuration file for lsyncd.

--

-- Simple example for default rsync, but executing moves through on the target.

--

-- For more examples, see /usr/share/doc/lsyncd*/examples/

--

-- (注释掉这行)sync{default.rsyncssh, source="/var/www/html", host="localhost", targetdir="/tmp/htmlcopy/"}


settings {

    logfile      ="/opt/king/lsyncd.log",

    statusFile   ="/opt/king/lsyncd.status",

    inotifyMode  = "CloseWrite",

    maxProcesses = 7,

    -- nodaemon =true,

}


sync {

    default.rsync,

    source    = "/opt/web",

    target    = "/opt/king",

    -- excludeFrom = "/etc/rsyncd.d/rsync_exclude.lst",

    rsync     = {

        binary    = "/usr/bin/rsync",

        archive   = true,

        compress  = true,

        verbose   = true

        }

}

2.跨服务器目录同步


参考:

https://linux.cn/article-5849-1.html