您的位置:首页 > 教程笔记 > 综合教程

syncthing在Linux上开机后自动运行方法和命令

2021-05-02 20:21:03 综合教程 123
要在Linux系统开机后自动运行syncthing,可以通过systemd服务来配置。以下是在Ubuntu操作系统上配置syncthing自启动的步骤:

创建一个新的systemd服务文件 /etc/systemd/system/syncthing.service,并将以下内容复制到文件中:

[Unit]
Description=Syncthing - Open Source Continuous File Synchronization
After=work.target
[Service]
User=<your_user_name>
ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0
Restart=on-failure
SuessExitStatus=3 4
RestartForceExitStatus=3 4
[Install]
WantedBy=multi-user.target

在上面的文件中,将 <your_user_name> 替换为您的用户名(例如,如果您的用户名为 "root",请将其替换为 "root")。

保存文件并退出。

在终端中输入以下命令,以重新加载systemd配置并启用syncthing服务:

sudo systemctl daemon-reload
sudo systemctl enable syncthing.service
sudo systemctl start syncthing.service
现在,syncthing将会在每次系统启动后自动运行。

ExecStart=/usr/bin/syncthing 这里有Syncthing路径
不知道可以用 which syncthing 命令来查
还有如果用户名不确定
可以用下面命令查 whoami

相关推荐