Syncthing Service Stopping When Logged Off

I have installed Syncthing 1.5.0 on Ubuntu 20.04 server and started up the service successfully. However, whenever I log off, the service is terminated until I log back in. How can I fix this?

1 Like

How did you start it? Do you have an encrypted home directory?

1 Like

I started it with the systemctl start syncthing@ command as well as the enable command. I do not have an encrypted home directory.

The sudo systemctl syncthing@username command or systemct --user syncthing@username? It needs to be the former. If that doesn’t work, look at journalctl -r -u syncthing@username to see why it’s stopping.

sudo systemctl syncthing@username The log says the process is receiving signal 15 when I log out.

That’s from the syncthing monitor when it is told to stop. The interesting bit is what systemd does with the service and why.

Here are the logs going up to that point (as best as I can tell these are the lines that are always present):

May 20 14:06:03 serversystemd[1]: Started Syncthing - Open Source Continuous File Synchronization for username.
May 20 14:06:03 serversystemd[1]: Stopped Syncthing - Open Source Continuous File Synchronization for username.
May 20 14:06:03 server systemd[1]: syncthing@username.service: Succeeded.
May 20 14:06:03 server syncthing[2141]: [Y2YIF] INFO: Exiting
May 20 14:06:03 server syncthing[2141]: [Y2YIF] INFO: TCP listener ([::]:22000) shutting down
May 20 14:06:03 server syncthing[2141]: [Y2YIF] INFO: Disconnected from relay relay://66.198.164.254:443
May 20 14:06:03 server systemd[1]: Stopping Syncthing - Open Source Continuous File Synchronization for username...
May 20 14:06:03 server syncthing[2141]: [Y2YIF] INFO: Relay listener (dynamic+https://relays.syncthing.net/endpoint) shu>
May 20 14:06:03 server syncthing[2141]: [Y2YIF] INFO: QUIC listener ([::]:22000) shutting down
May 20 14:06:03 server syncthing[2141]: [monitor] INFO: Signal 15 received; exiting

The -r reverts the logs, so if there is anything interesting, it’s below this. Anyway this is a (handling of) systemd problem, not a Syncthing problem.

By default, when you log out of systemd, it stops your services, since you are no longer there.

You can make your user “linger” even when logged out with loginctl, with the enable-linger command.

Or you can change the value of systemd’s KillUserProcesses option, but that will affect all users AFAIK.

That only applies to user services, i.e. starting with the --user flag. That’s what I asked about above and they do run system services, i.e. no --user flag. In which case it doesn’t matter whether a user is logging in or out.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.