1. 创建 systemd 服务文件

    首先,创建一个新的 systemd 服务文件:

    sudo nano /etc/systemd/system/syncthing.service
  2. 添加以下内容到服务文件

    [Unit]
    Description=Syncthing - Open Source Continuous File Synchronization
    Documentation=https://docs.syncthing.net/
    After=network.target
    
    [Service]
    User=your_username
    ExecStart=/opt/syncthing/syncthing -no-browser
    Restart=on-failure
    RestartSec=5
    
    [Install]
    WantedBy=multi-user.target

    请将 your_username 替换为实际的用户名。

  3. 重新加载 systemd 配置

    sudo systemctl daemon-reload
  4. 启用并启动 Syncthing 服务

    sudo systemctl enable syncthing
    sudo systemctl start syncthing

检查 Syncthing 状态

使用以下命令来检查 Syncthing 是否正在运行:

systemctl status syncthing

或者,如果你使用了 init.d

sudo service syncthing status

标签: linux, 自启动, syncthing

添加新评论