需求:想把每天60s读懂世界的图片,同步到windows机器上,用微信机器人定时发给群/好友。
由于window服务器上cmd脚本写着麻烦,还需要开定时器啥的,没有linux顺手。于是使用raspberry树莓派闲置服务器,用shell脚本或其他语言很容易实现定时下载文件到指定文件夹。
下面记录在linux下安装 syncthing过程
# Add the release PGP keys:
sudo curl -s -o /usr/share/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg
# Update and install syncthing:
sudo apt-get update
sudo apt-get install syncthing
# out put log
> Created symlink /etc/systemd/system/sleep.target.wants/syncthing-resume.service → /lib/systemd/system/syncthing-resume.service.
> systemctl stop syncthing-resume.service
> systemctl start syncthing-resume.service
# 下面这句话可以开启一个服务
syncthing --gui-address=0.0.0.0:8384
#创建一个自启动脚本
vi /etc/systemd/system/synchting.service
# 参考 https://github.com/syncthing/syncthing/blob/main/etc/linux-systemd/system/syncthing%40.service 但是改了第30行
```
[Unit]
Description=Syncthing - Open Source Continuous File Synchronization for %I
Documentation=man:syncthing(1)
After=network.target
StartLimitIntervalSec=60
StartLimitBurst=4
[Service]
User=root
ExecStart=/usr/bin/syncthing --gui-address=0.0.0.0:8384 --no-restart --logflags=0
Restart=on-failure
RestartSec=1
SuccessExitStatus=3 4
RestartForceExitStatus=3 4
# Hardening
ProtectSystem=full
PrivateTmp=true
SystemCallArchitectures=native
MemoryDenyWriteExecute=true
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
```
systemctl enable synchting.service
systemctl restart synchting.service
参考链接: