systemd user service not found after reboot











up vote
3
down vote

favorite












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.










share|improve this question

















This question has an open bounty worth +50
reputation from Adam Monsen ending in 4 days.


This question has not received enough attention.
















  • 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 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
    yesterday










  • Is your home folder encrypted? (ecryptfs?)
    – pim
    yesterday










  • Yes, I have an encrypted home dir
    – Adam Monsen
    21 hours ago















up vote
3
down vote

favorite












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.










share|improve this question

















This question has an open bounty worth +50
reputation from Adam Monsen ending in 4 days.


This question has not received enough attention.
















  • 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 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
    yesterday










  • Is your home folder encrypted? (ecryptfs?)
    – pim
    yesterday










  • Yes, I have an encrypted home dir
    – Adam Monsen
    21 hours ago













up vote
3
down vote

favorite









up vote
3
down vote

favorite











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.










share|improve this question















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.







18.04 systemd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 7 at 20:33

























asked Nov 6 at 23:39









Adam Monsen

1,05121127




1,05121127






This question has an open bounty worth +50
reputation from Adam Monsen ending in 4 days.


This question has not received enough attention.








This question has an open bounty worth +50
reputation from Adam Monsen ending in 4 days.


This question has not received enough attention.














  • 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 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
    yesterday










  • Is your home folder encrypted? (ecryptfs?)
    – pim
    yesterday










  • Yes, I have an encrypted home dir
    – Adam Monsen
    21 hours ago


















  • 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 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
    yesterday










  • Is your home folder encrypted? (ecryptfs?)
    – pim
    yesterday










  • Yes, I have an encrypted home dir
    – Adam Monsen
    21 hours ago
















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 at 7:33




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 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
yesterday




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
yesterday












Is your home folder encrypted? (ecryptfs?)
– pim
yesterday




Is your home folder encrypted? (ecryptfs?)
– pim
yesterday












Yes, I have an encrypted home dir
– Adam Monsen
21 hours ago




Yes, I have an encrypted home dir
– Adam Monsen
21 hours ago










2 Answers
2






active

oldest

votes

















up vote
0
down vote













It seems you have met a known bug, that can be fixed by changing the order of two lines in /etc/pam.d/common-session from



session optional pam_systemd.so
session optional pam_ecryptfs.so unwrap


to



session optional pam_ecryptfs.so unwrap
session optional pam_systemd.so


Starting the service before login



Since the user directory (where your service is stored) is encrypted before login, this service can't be started before login. Anyway before login (unencryption), syncthing would have nowhere to read/write.



Security warning



This service may let the user home directory unencrypted after the logout (another bug, see this question).






share|improve this answer




























    up vote
    0
    down vote













    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






    share|improve this answer





















      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "89"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














       

      draft saved


      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1090634%2fsystemd-user-service-not-found-after-reboot%23new-answer', 'question_page');
      }
      );

      Post as a guest
































      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      0
      down vote













      It seems you have met a known bug, that can be fixed by changing the order of two lines in /etc/pam.d/common-session from



      session optional pam_systemd.so
      session optional pam_ecryptfs.so unwrap


      to



      session optional pam_ecryptfs.so unwrap
      session optional pam_systemd.so


      Starting the service before login



      Since the user directory (where your service is stored) is encrypted before login, this service can't be started before login. Anyway before login (unencryption), syncthing would have nowhere to read/write.



      Security warning



      This service may let the user home directory unencrypted after the logout (another bug, see this question).






      share|improve this answer

























        up vote
        0
        down vote













        It seems you have met a known bug, that can be fixed by changing the order of two lines in /etc/pam.d/common-session from



        session optional pam_systemd.so
        session optional pam_ecryptfs.so unwrap


        to



        session optional pam_ecryptfs.so unwrap
        session optional pam_systemd.so


        Starting the service before login



        Since the user directory (where your service is stored) is encrypted before login, this service can't be started before login. Anyway before login (unencryption), syncthing would have nowhere to read/write.



        Security warning



        This service may let the user home directory unencrypted after the logout (another bug, see this question).






        share|improve this answer























          up vote
          0
          down vote










          up vote
          0
          down vote









          It seems you have met a known bug, that can be fixed by changing the order of two lines in /etc/pam.d/common-session from



          session optional pam_systemd.so
          session optional pam_ecryptfs.so unwrap


          to



          session optional pam_ecryptfs.so unwrap
          session optional pam_systemd.so


          Starting the service before login



          Since the user directory (where your service is stored) is encrypted before login, this service can't be started before login. Anyway before login (unencryption), syncthing would have nowhere to read/write.



          Security warning



          This service may let the user home directory unencrypted after the logout (another bug, see this question).






          share|improve this answer












          It seems you have met a known bug, that can be fixed by changing the order of two lines in /etc/pam.d/common-session from



          session optional pam_systemd.so
          session optional pam_ecryptfs.so unwrap


          to



          session optional pam_ecryptfs.so unwrap
          session optional pam_systemd.so


          Starting the service before login



          Since the user directory (where your service is stored) is encrypted before login, this service can't be started before login. Anyway before login (unencryption), syncthing would have nowhere to read/write.



          Security warning



          This service may let the user home directory unencrypted after the logout (another bug, see this question).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 5 hours ago









          pim

          1,830824




          1,830824
























              up vote
              0
              down vote













              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






              share|improve this answer

























                up vote
                0
                down vote













                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






                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  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






                  share|improve this answer












                  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







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 3 hours ago









                  solsTiCe

                  5,09221745




                  5,09221745






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1090634%2fsystemd-user-service-not-found-after-reboot%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest




















































































                      Popular posts from this blog

                      Quarter-circle Tiles

                      build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

                      Mont Emei