因此我安装了守护进程并将其配置为:
matias@~
$ cat /etc/lsyncd/lsyncd.conf.lua
settings {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/tmp/lsyncd.stat",
statusInterval = 1,
verbose = false,
}
sync {
default.rsync,
source = '/home/matias/Remoto',
target = '[email protected]:./Remoto',
delay = 1,
rsync= {
owner = true,
perms = true,
group = true,
acls = true,
verbose = true,
rsh = "/usr/bin/ssh -i /home/matias/.ssh/id_rsa.pub -p 22 -o StrictHostKeyChecking=no"
}
}
我可以看到守护进程已启动并正在运行:
matias@~
$ sudo systemctl status lsyncd
[sudo] password for matias:
● lsyncd.service - LSB: lsyncd daemon init script
Loaded: loaded (/etc/init.d/lsyncd; bad; vendor preset: enabled)
Active: active (exited) since jue 2020-01-23 16:18:05 -03; 3h 28min ago
Docs: man:systemd-sysv-generator(8)
Process: 13723 ExecStop=/etc/init.d/lsyncd stop (code=exited, status=0/SUCCESS
Process: 13731 ExecStart=/etc/init.d/lsyncd start (code=exited, status=0/SUCCE
ene 23 16:18:05 lenovoI5 systemd[1]: Starting LSB: lsyncd daemon init script...
ene 23 16:18:05 lenovoI5 lsyncd[13731]: * Starting synchronization daemon lsync
ene 23 16:18:05 lenovoI5 lsyncd[13731]: ...done.
ene 23 16:18:05 lenovoI5 systemd[1]: Started LSB: lsyncd daemon init script.
如果我运行 journalctl 我可以看到以下内容:
matias@~
$ sudo journalctl -u lsyncd
-- Logs begin at jue 2020-01-23 10:20:58 -03, end at jue 2020-01-23 19:47:45 -03
......
ene 23 16:06:46 lenovoI5 lsyncd[13218]: Error: error preparing /etc/lsyncd/lsync
ene 23 16:06:46 lenovoI5 lsyncd[13218]: ...fail!
ene 23 16:18:05 lenovoI5 systemd[1]: Starting LSB: lsyncd daemon init script...
ene 23 16:18:05 lenovoI5 lsyncd[13731]: * Starting synchronization daemon lsync
ene 23 16:18:05 lenovoI5 lsyncd[13731]: ...done.
ene 23 16:18:05 lenovoI5 systemd[1]: Started LSB: lsyncd daemon init script
这行证明它确实读取了配置文件,并且我对其进行了更正:
ene 23 16:06:46 lenovoI5 lsyncd[13218]: Error: error preparing /etc/lsyncd/lsyncd.conf.lua: Parameter "identityFile" unknown. (if this is not a ty
ene 23 16:06:46 lenovoI5 lsyncd[13218]: ...fail!
我可以看到正在创建的统计日志:
matias@~
$ cat /tmp/lsyncd.stat
Lsyncd status report at Thu Jan 23 16:18:05 2020
Sync1 source=/home/matias/Remoto/
There are 1 delays
active Init
Excluding:
nothing.
Inotify watching 4 directories
1: /home/matias/Remoto/
2: /home/matias/Remoto/Documentos/
3: /home/matias/Remoto/Archivos/
4: /home/matias/Remoto/Mas/
问题是,远程服务器上的文件和目录未同步。我重新启动服务后创建了文件夹 Mas,但 1 小时后它仍未更新。
奇怪的是,当我手动运行它时它确实起作用了:
lsyncd /etc/lsyncd/lsyncd.conf.lua
我究竟做错了什么?