Syncthing 维护指南

本章节主要介绍 Syncthing 的日常运维操作,包括服务管理、日志排查、权限问题以及常见故障处理。


服务管理(systemd)

Syncthing 通常以 systemd 服务运行:

1
systemctl status syncthing@syncthing

启动 / 停止 / 重启

1
2
3
4
5
6
7
8
# 启动
systemctl start syncthing@syncthing

# 停止
systemctl stop syncthing@syncthing

# 重启
systemctl restart syncthing@syncthing

检查是否开机自启动(重点)

1
systemctl is-enabled syncthing@syncthing

返回:

  • enabled → 已开机启动
  • disabled → 未启用

设置开机自启动

1
systemctl enable syncthing@syncthing

取消开机自启动

1
systemctl disable syncthing@syncthing

日志查看(排错核心)

实时日志:

1
journalctl -u syncthing@syncthing -f

查看最近日志:

1
journalctl -u syncthing@syncthing --since "1 hour ago"

常见日志问题:

permission denied

说明权限不足:

需要检查目录归属

1
chown -R syncthing:syncthing /your/folder

权限问题(高频问题)

Syncthing 不会自动修复权限。

正确设置: 例: 给 /site 目录设置权限

1
2
chown -R syncthing:syncthing /site
chmod -R 755 /site

查看目录属于哪个用户

1
ls -ld /site

关键是这一段:

drwxr-xr-x

拆解:

位置含义
d目录
rwx所有者权限
r-x组权限
r-x其他用户权限

权限含义

字符含义
r可读(read)
w可写(write)
x可执行(目录表示可进入)

用数字方式查看权限(更清晰)

1
stat /site

输出示例:

  File: /site
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: 254,1   Inode: 524289      Links: 11
Access: (0755/drwxr-xr-x)  Uid: ( 1000/syncthing)   Gid: ( 1000/syncthing)
Access: 2026-04-09 07:53:58.865939821 +0530
Modify: 2026-04-07 09:30:12.473021927 +0530
Change: 2026-04-09 07:17:06.981783777 +0530
 Birth: 2026-04-07 09:29:09.726524648 +0530

这里可以直接看到:

权限:0755

用户:syncthing

组:syncthing

测试权限

测试读取权限

1
runuser -u syncthing -- ls /site

这条命令的真实意思是:

syncthing 用户的权限,执行 ls /site


测试写权限

使用 syncthing 用户的权限,在/site目录中创建 test 目录

1
runuser -u syncthing -- touch /site/test

测试删除权限

使用 syncthing 用户的权限,在/site目录中删除 test 目录

1
runuser -u syncthing -- rm /site/test

递归查看(排查用)

查看目录及子文件:

1
ls -l /site

如果很多文件:

1
ls -l /site | head

网络与端口检查

默认使用:

端口协议用途
8384TCPWEB
22000TCP同步
22000UDPQUIC

检查端口监听:

1
ss -tulnp | grep 22000