配置Lsyncd同步不同目录内容
详细步骤

1. 安装Lsyncd
安装Lsyncd命令
sudo apt install lsyncd -y测试已经正确安装
lsyncd --version2. 配置Lsyncd
为配置文件创建目录
sudo mkdir /etc/lsyncd为日志文件创建目录
sudo mkdir /var/log/lsyncd/创建配置文件
sudo nano /etc/lsyncd/lsyncd.conf.lua在配置文件中写入以下内容
settings {
ogfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd.status",
statusInterval = 20,
nodaemon = false
}
sync {
default.rsync,
source = "/etc/",
target = "/mnt"
}完成后保存并关闭文件。
3. Lsyncd服务
启动服务
sudo systemctl start lsyncd开机自启
sudo systemctl enable lsyncd查看服务状态
sudo systemctl status lsyncd成功启动服务会显示如下信息
Active: active (running)4. Lsyncd日志
查看日志获取详细运行信息
tail -f /var/log/lsyncd/lsyncd.log检查目录同步状态
tail -f /var/log/lsyncd/lsyncd.status资料引用
https://www.howtoforge.com/how-to-synchronize-directories-using-lsyncd-on-ubuntu/?ref=ghost.bayview.top