I am running Mageia 9, and I have not been able to make Syncthing autostart. I have tried the following configurations:
1 Using XDG autostart:
~/.local/bin/syncthing (executable)
~/.local/share/applications/syncthing-start.desktop (desktop file modified for executable path)
~/.config/autostart/syncthing-start.desktop (symlink to desktop file)
2 Using systemd user service:
~/.local/bin/syncthing (executable)
~/.config/systemd/user/syncthing.service (service file modified for executable path, using %h and absolute)
Both of these methods work for other applications and the problem persists across multiple computers. Attempts to write a log file have been unsuccessful. It runs normally if started manually.
Just to make sure I understand, there are no Syncthing log entries when it fails? And no systemd log entries when using that method? If you use the —-logfile command-line option in your configuration, does that change anything?
Because generally speaking this would require logging in and not logging off in order for Syncthing to continue running, using systemd is a better choice.
What is the output from systemctl --user status syncthing?
Would you mind sharing the contents of~/.config/systemd/user/syncthing.service?
You didn’t indicated how you used the user systemd service, aka enabling or starting. The status output shows it’s disabled, so it wont start on loging as expected. What happens is you run systemd --user start syncthing? There should then be logs, or if your systemd logging setup is borked, the status command should show some info. Also just for good measure I’d try commenting out the hardening options.
As already mentioned, your Syncthing service isn’t enabled to autostart at login or at boot time.
To enable the Syncthing service to autostart for your user account:
systemctl --user enable syncthing
Note that the above command will only autostart Syncthing during log in, and will also stop Syncthing when you log off. So if you want Syncthing to autostart at boot time and also persist when you log off, tell systemd’s login manager to allow it:
Thanks! I had been missing sytemctl --user enable syncthing and now everything seems to work. Not sure why my other user service didn’t need that, nor what was wrong with the XDG autostart (this had been my go-to in the past), but these are both questions for another time.
… It’s an easy and common one to miss because it seems like adding the service unit file would be enough, similar to XDG’s autostart.
On my NAS, I start Syncthing at boot time with a syncthing.timer unit file that adds a 15-minute delay to give the OS a chance to take care of any filesystem errors first.
For XDG, it could be the desktop environment, because not all support it.