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?
With unprivileged user services (like Syncthing) on systemd, logs go to the user’s journal. They can be accessed like this:
$ journalctl --user-unit syncthing
The advantages of using systemd over /etc/rc.local are the same advantages of systemd in general.
When I do “journalctl --user-unit syncthing” I get nothing:-
chris$ journalctl --user-unit syncthing
-- Logs begin at Mon 2018-07-02 22:58:45 BST, end at Fri 2018-08-17 19:55:11 BST. --
-- No entries --
I’m sure there should be something logged in the past several weeks.
I realize this question is a bit systemd rather than syncthing so sorry for that.
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 firstname.lastname@example.org, view the logs with
journalctl r -u email@example.com.
-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.
OK, that doesn’t help much.
Run this, paste the output:
systemctl list-unit-files | grep syncthing
Thanks for all the help, here’s the result:-
chris$ systemctl list-unit-files | grep syncthing
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.
â firstname.lastname@example.org - 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
email@example.com? That means it’s running as the
journalctl -r -u firstname.lastname@example.org (so that it matches the line from the top of the
systemctl status command). That should give you your logs.
Aha, you’ve got me there.
journalctl -r -u email@example.com
gets the logs. Thank you!
Cool! You’ll have set it to start with
systemctl enable firstname.lastname@example.org
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.