I run syncthing on a mixture of xubuntu, raspbian and other Debian derived systems.
I use the syncthing PPA to keep them all in step at the latest stable syncthing.
I just noticed that on one system syncthing is being started by systemd (i.e. there’s a file /usr/lib/systemd/user/syncthing.service) whereas on all the other systems I’m starting syncthing from /etc/rc.local. (On the system where systemd runs syncthing I was also starting it from rc.local but after a few retries that syncthing gives up). Does installing from the syncthing PPA attempt to add the systemd startup? If not then where did I get that from because I’m pretty sure I didn’t do it!
Is there any advantage/disadvantage in using systemd rather than /etc/rc.local? I have a python script catching errors from syncthing when it’s started from rc.local. Where does systemd put the syncthing log and errors?
It depends how you started Syncthing. Systemd can start services in two ways: as a user service, which starts when the user logs in, or as a system service, which starts when the system starts.
If you started Syncthing with something like systemctl start --user syncthing.service, then view the logs with something like journalctl -r --user -u syncthing.service. If you started it with something like systemctl start syncthing@user.service, view the logs with journalctl r -u syncthing@user.service.
The -r shows the logs newest to oldest. Use -f to see print logs as they’re logged.
I didn’t start syncthing, I installed it using ‘apt install syncthing’ and as a result I seem to be running syncthing via systemd. So I have a file /usr/lib/systemd/user/symcthing.service which runs syncthing at startup.
If I can find the logs then I’m happy with this set-up but otherwise I think I’ll get rid of it and run from /etc/rc.local.
Right, so it’s started as a system service, not a user service.
Let’s find out what user it’s running as. Run
systemctl status syncthing@*.service
See what it says at the top, e.g.
â syncthing@syncthing.service - Syncthing - Open Source Continuous File Synchronization for syncthing
Loaded: loaded (/usr/lib/systemd/system/syncthing@.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2018-08-12 14:05:58 BST; 5 days ago
See that it says syncthing@syncthing.service? That means it’s running as the syncthing user.
Then run journalctl -r -u syncthing@syncthing.service (so that it matches the line from the top of the systemctl status command). That should give you your logs.