How to configure Systemd User Service with a Timer

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I have a systemd user service that works as expected. It is started like this:



systemctl start test@user


The problem is that I need to run this service on a timer possibly for multiple users. There doesn't seem to be a way to specify a user in the timer itself or a way to pass the username with the @ notation.



Here is the timer:



[Unit]
Description=Test (runs once every 24 hours)

[Timer]
OnUnitActiveSec=24h
Persistent=true
Unit=test@.service

[Install]
WantedBy=timers.target


What confuses me is what to put in the "Unit=".
If I put in "test@user.service" it works but then it will always run as a single user defeating the point of having a multi user service. Using "test@.service" starts the timer but "systemctl status test@user" shows it as always inactive even with timer set to 1min interval.



I am not sure how to list the all running instances of a given systemd service so I don't know if "test@" service is running as a different user when a timer runs the service without the "@user".



What is the proper way to start user services with a timer? Ideally users should be able to create and manage their own services as well as timers that go along those services.










share|improve this question

























    up vote
    2
    down vote

    favorite












    I have a systemd user service that works as expected. It is started like this:



    systemctl start test@user


    The problem is that I need to run this service on a timer possibly for multiple users. There doesn't seem to be a way to specify a user in the timer itself or a way to pass the username with the @ notation.



    Here is the timer:



    [Unit]
    Description=Test (runs once every 24 hours)

    [Timer]
    OnUnitActiveSec=24h
    Persistent=true
    Unit=test@.service

    [Install]
    WantedBy=timers.target


    What confuses me is what to put in the "Unit=".
    If I put in "test@user.service" it works but then it will always run as a single user defeating the point of having a multi user service. Using "test@.service" starts the timer but "systemctl status test@user" shows it as always inactive even with timer set to 1min interval.



    I am not sure how to list the all running instances of a given systemd service so I don't know if "test@" service is running as a different user when a timer runs the service without the "@user".



    What is the proper way to start user services with a timer? Ideally users should be able to create and manage their own services as well as timers that go along those services.










    share|improve this question























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I have a systemd user service that works as expected. It is started like this:



      systemctl start test@user


      The problem is that I need to run this service on a timer possibly for multiple users. There doesn't seem to be a way to specify a user in the timer itself or a way to pass the username with the @ notation.



      Here is the timer:



      [Unit]
      Description=Test (runs once every 24 hours)

      [Timer]
      OnUnitActiveSec=24h
      Persistent=true
      Unit=test@.service

      [Install]
      WantedBy=timers.target


      What confuses me is what to put in the "Unit=".
      If I put in "test@user.service" it works but then it will always run as a single user defeating the point of having a multi user service. Using "test@.service" starts the timer but "systemctl status test@user" shows it as always inactive even with timer set to 1min interval.



      I am not sure how to list the all running instances of a given systemd service so I don't know if "test@" service is running as a different user when a timer runs the service without the "@user".



      What is the proper way to start user services with a timer? Ideally users should be able to create and manage their own services as well as timers that go along those services.










      share|improve this question













      I have a systemd user service that works as expected. It is started like this:



      systemctl start test@user


      The problem is that I need to run this service on a timer possibly for multiple users. There doesn't seem to be a way to specify a user in the timer itself or a way to pass the username with the @ notation.



      Here is the timer:



      [Unit]
      Description=Test (runs once every 24 hours)

      [Timer]
      OnUnitActiveSec=24h
      Persistent=true
      Unit=test@.service

      [Install]
      WantedBy=timers.target


      What confuses me is what to put in the "Unit=".
      If I put in "test@user.service" it works but then it will always run as a single user defeating the point of having a multi user service. Using "test@.service" starts the timer but "systemctl status test@user" shows it as always inactive even with timer set to 1min interval.



      I am not sure how to list the all running instances of a given systemd service so I don't know if "test@" service is running as a different user when a timer runs the service without the "@user".



      What is the proper way to start user services with a timer? Ideally users should be able to create and manage their own services as well as timers that go along those services.







      arch-linux systemd services






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 23 '15 at 16:21









      DominicM

      249620




      249620




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Does that answer what you need?



          systemctl --user start unit.service





          share|improve this answer




















          • Adding some explanation why it would do so would be nice.
            – phk
            Aug 9 at 9:13










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          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: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f224954%2fhow-to-configure-systemd-user-service-with-a-timer%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          Does that answer what you need?



          systemctl --user start unit.service





          share|improve this answer




















          • Adding some explanation why it would do so would be nice.
            – phk
            Aug 9 at 9:13














          up vote
          0
          down vote













          Does that answer what you need?



          systemctl --user start unit.service





          share|improve this answer




















          • Adding some explanation why it would do so would be nice.
            – phk
            Aug 9 at 9:13












          up vote
          0
          down vote










          up vote
          0
          down vote









          Does that answer what you need?



          systemctl --user start unit.service





          share|improve this answer












          Does that answer what you need?



          systemctl --user start unit.service






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Aug 9 at 4:31









          EarthMind

          1234




          1234











          • Adding some explanation why it would do so would be nice.
            – phk
            Aug 9 at 9:13
















          • Adding some explanation why it would do so would be nice.
            – phk
            Aug 9 at 9:13















          Adding some explanation why it would do so would be nice.
          – phk
          Aug 9 at 9:13




          Adding some explanation why it would do so would be nice.
          – phk
          Aug 9 at 9:13

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f224954%2fhow-to-configure-systemd-user-service-with-a-timer%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          The Forum (Inglewood, California)

          Palaiologos