6

I set up syncthing as a systemd user service on a 16.04 computer. Worked fine. Since I upgraded to 18.04 the service disappears upon reboot.

After rebooting, I see:

$ systemctl --user status syncthing.service 
Unit syncthing.service could not be found.

And syncthing is indeed not running.

Here is ~/.config/systemd/user/syncthing.service (following the example, but note the binary is under my home dir):

[Unit]
Description=Syncthing - Open Source Continuous File Synchronization
Documentation=man:syncthing(1)

[Service]
ExecStart=/home/user/syncthing-prefix/syncthing -no-browser -no-restart -logflags=0
Restart=on-failure
SuccessExitStatus=3 4
RestartForceExitStatus=3 4

[Install]
WantedBy=default.target

I then run this:

$ systemctl --user enable syncthing.service
$ systemctl --user start syncthing.service

Following the setup instructions I used to install the user service originally.

After running the above two commands, I see:

$ systemctl --user status syncthing.service
● syncthing.service - Syncthing - Open Source Continuous File Synchronization
  Loaded: loaded (/home/user/.config/systemd/user/syncthing.service; enabled; 
  Active: active (running) since Tue 2018-11-06 15:28:16 PST; 4s ago
    Docs: man:syncthing(1)
Main PID: 4221 (syncthing)
  CGroup: /user.slice/user-1000.slice/user@1000.service/syncthing.service
          └─4221 /home/user/syncthing-prefix/syncthing -no-b

Nov 06 15:28:18 kind syncthing[4221]: [XXXXX] INFO: Device XXXXXXX-XXXXXXX-XXXXX
Nov 06 15:28:18 kind syncthing[4221]: [XXXXX] INFO: Device XXXXXXX-XXXXXXX-XXXXX
Nov 06 15:28:18 kind syncthing[4221]: [XXXXX] INFO: Device XXXXXXX-XXXXXXX-XXXXX
Nov 06 15:28:18 kind syncthing[4221]: [XXXXX] INFO: GUI and API listening on 127
Nov 06 15:28:18 kind syncthing[4221]: [XXXXX] INFO: Access the GUI via the follo
Nov 06 15:28:18 kind syncthing[4221]: [XXXXX] INFO: Completed initial scan of se
Nov 06 15:28:18 kind syncthing[4221]: [XXXXX] INFO: Completed initial scan of se
Nov 06 15:28:18 kind syncthing[4221]: [XXXXX] INFO: Completed initial scan of se
Nov 06 15:28:19 kind syncthing[4221]: [XXXXX] INFO: Completed initial scan of se
Nov 06 15:28:20 kind syncthing[4221]: [XXXXX] INFO: Completed initial scan of se

as expected. And syncthing then works, as expected, until the next reboot.

Note that I have an encrypted home dir. This was the case when I was using 16.04, too.

4
  • Are you trying to start a service before logging in with the user? This should be enable using sudo loginctl enable-linger USERNAME – pim Nov 12 '18 at 7:33
  • It could happen right when I log in or before. This set Linger: yes but didn't fix the reported issue on my machine. – Adam Monsen Nov 14 '18 at 2:17
  • Is your home folder encrypted? (ecryptfs?) – pim Nov 14 '18 at 5:40
  • Yes, I have an encrypted home dir – Adam Monsen Nov 14 '18 at 16:47
0

You have the same problem than https://unix.stackexchange.com/q/417162/116970

I would suggest that you add a After= and a Requires= line on your syncthing.service in the [Unit] section so that syncthing is run after the home folder is mounted.

More spefically, you coud try:

[Unit]
Description=Syncthing - Open Source Continuous File Synchronization
Documentation=man:syncthing(1)
After=home-yourusername.mount
Requires=home-yourusername.mount

...

and replace yourusername with your user name

1
  • This didn't resolve the issue. I made this change, disabled the service, ran systemctl --user daemon-reload, enabled the service, and rebooted. – Adam Monsen Nov 16 '18 at 22:20
0

Credit to https://unix.stackexchange.com/questions/417162/use-systemd-user-services-with-ecryptfs/545704#545704


It's a bug in the ecryptfs package configuration. You can use a quick fix: Open /etc/pam.d/common-session and switch the lines

session optional        pam_systemd.so
session optional        pam_ecryptfs.so unwrap

to

session optional        pam_ecryptfs.so unwrap
session optional        pam_systemd.so

so that pam_systemd.so is loaded after pam_ecryptfs.so

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.