所以我安裝了守護程式並將其配置為:
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
我究竟做錯了什麼?