Which is the correct way to disable a systemd timer unit?

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











up vote
13
down vote

favorite
1












I've successfully migrated a few of my cron jobs over to systemd. I followed some guides and have taken the standard approach of creating 3 files:



myjob.timer - systemd timer unit
myjob.service - systemd service unit
myjob.sh


As you can probably guess, at a certain time myjob.timer is triggered, which runs myjob.service which in turn executes myjob.sh.



I have the same setup for all of my timers and now that I see everything is working fine I want to disable myjob.timer, which is just a tester.



Do I just do:



systemctl --user disable myjob.timer


or do I also have to do:



systemctl --user disable myjob.service


What is the correct thing to do? I'm quite new to systemd, so I'd like to learn how to do stuff the proper way. I'm guessing that it's correct to disable both units in order to keep the system free of excess baggage running.










share|improve this question

























    up vote
    13
    down vote

    favorite
    1












    I've successfully migrated a few of my cron jobs over to systemd. I followed some guides and have taken the standard approach of creating 3 files:



    myjob.timer - systemd timer unit
    myjob.service - systemd service unit
    myjob.sh


    As you can probably guess, at a certain time myjob.timer is triggered, which runs myjob.service which in turn executes myjob.sh.



    I have the same setup for all of my timers and now that I see everything is working fine I want to disable myjob.timer, which is just a tester.



    Do I just do:



    systemctl --user disable myjob.timer


    or do I also have to do:



    systemctl --user disable myjob.service


    What is the correct thing to do? I'm quite new to systemd, so I'd like to learn how to do stuff the proper way. I'm guessing that it's correct to disable both units in order to keep the system free of excess baggage running.










    share|improve this question























      up vote
      13
      down vote

      favorite
      1









      up vote
      13
      down vote

      favorite
      1






      1





      I've successfully migrated a few of my cron jobs over to systemd. I followed some guides and have taken the standard approach of creating 3 files:



      myjob.timer - systemd timer unit
      myjob.service - systemd service unit
      myjob.sh


      As you can probably guess, at a certain time myjob.timer is triggered, which runs myjob.service which in turn executes myjob.sh.



      I have the same setup for all of my timers and now that I see everything is working fine I want to disable myjob.timer, which is just a tester.



      Do I just do:



      systemctl --user disable myjob.timer


      or do I also have to do:



      systemctl --user disable myjob.service


      What is the correct thing to do? I'm quite new to systemd, so I'd like to learn how to do stuff the proper way. I'm guessing that it's correct to disable both units in order to keep the system free of excess baggage running.










      share|improve this question













      I've successfully migrated a few of my cron jobs over to systemd. I followed some guides and have taken the standard approach of creating 3 files:



      myjob.timer - systemd timer unit
      myjob.service - systemd service unit
      myjob.sh


      As you can probably guess, at a certain time myjob.timer is triggered, which runs myjob.service which in turn executes myjob.sh.



      I have the same setup for all of my timers and now that I see everything is working fine I want to disable myjob.timer, which is just a tester.



      Do I just do:



      systemctl --user disable myjob.timer


      or do I also have to do:



      systemctl --user disable myjob.service


      What is the correct thing to do? I'm quite new to systemd, so I'd like to learn how to do stuff the proper way. I'm guessing that it's correct to disable both units in order to keep the system free of excess baggage running.







      systemd systemd-timer






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 8 '17 at 15:13









      bitofagoob

      455417




      455417




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          9
          down vote



          accepted










          if myjob.service contains no [Install] block, then it is sufficient to just disable the timer. The timer was the only thing starting the .service file, so with the .timer disabled, nothing will start the .service file.



          Also remember to run systemctl --user stop myjob.timer. Disabling the timer prevents it from being started on the next boot, but it does not stop the timer currently running.






          share|improve this answer






















          • I have an [Install] block in each of my timer units. It has one entry, saying 'WantedBy=default.target'. I got this from the guides I followed. Can I just get rid of the [Install] block altogether?
            – bitofagoob
            May 8 '17 at 15:44






          • 1




            OK. I have read about the [Install] section and I think that WantedBy=default.target is just there to ensure that the unit, when enabled, is brought to life during any normal boot session (either multi-user or graphical). I will take Mark Stosberg's advice and disable only the timer unit. I will also mark his answer as the solution. Cheers Mark!
            – bitofagoob
            May 8 '17 at 15:54






          • 2




            You want the [Install] section on your timer units so they are started on boot. Usually WantedBy=timers.target. You only need an [Install] section for a service if you want the service to be started at boot time, which it sounds like you don't want in this case.
            – Mark Stosberg
            May 8 '17 at 17:22







          • 1




            Thanks. I have removed the [Install] section from the service unit and changed the [Install] section in my timer to WantedBy=timers.target.
            – bitofagoob
            May 8 '17 at 17:34










          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%2f363728%2fwhich-is-the-correct-way-to-disable-a-systemd-timer-unit%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
          9
          down vote



          accepted










          if myjob.service contains no [Install] block, then it is sufficient to just disable the timer. The timer was the only thing starting the .service file, so with the .timer disabled, nothing will start the .service file.



          Also remember to run systemctl --user stop myjob.timer. Disabling the timer prevents it from being started on the next boot, but it does not stop the timer currently running.






          share|improve this answer






















          • I have an [Install] block in each of my timer units. It has one entry, saying 'WantedBy=default.target'. I got this from the guides I followed. Can I just get rid of the [Install] block altogether?
            – bitofagoob
            May 8 '17 at 15:44






          • 1




            OK. I have read about the [Install] section and I think that WantedBy=default.target is just there to ensure that the unit, when enabled, is brought to life during any normal boot session (either multi-user or graphical). I will take Mark Stosberg's advice and disable only the timer unit. I will also mark his answer as the solution. Cheers Mark!
            – bitofagoob
            May 8 '17 at 15:54






          • 2




            You want the [Install] section on your timer units so they are started on boot. Usually WantedBy=timers.target. You only need an [Install] section for a service if you want the service to be started at boot time, which it sounds like you don't want in this case.
            – Mark Stosberg
            May 8 '17 at 17:22







          • 1




            Thanks. I have removed the [Install] section from the service unit and changed the [Install] section in my timer to WantedBy=timers.target.
            – bitofagoob
            May 8 '17 at 17:34














          up vote
          9
          down vote



          accepted










          if myjob.service contains no [Install] block, then it is sufficient to just disable the timer. The timer was the only thing starting the .service file, so with the .timer disabled, nothing will start the .service file.



          Also remember to run systemctl --user stop myjob.timer. Disabling the timer prevents it from being started on the next boot, but it does not stop the timer currently running.






          share|improve this answer






















          • I have an [Install] block in each of my timer units. It has one entry, saying 'WantedBy=default.target'. I got this from the guides I followed. Can I just get rid of the [Install] block altogether?
            – bitofagoob
            May 8 '17 at 15:44






          • 1




            OK. I have read about the [Install] section and I think that WantedBy=default.target is just there to ensure that the unit, when enabled, is brought to life during any normal boot session (either multi-user or graphical). I will take Mark Stosberg's advice and disable only the timer unit. I will also mark his answer as the solution. Cheers Mark!
            – bitofagoob
            May 8 '17 at 15:54






          • 2




            You want the [Install] section on your timer units so they are started on boot. Usually WantedBy=timers.target. You only need an [Install] section for a service if you want the service to be started at boot time, which it sounds like you don't want in this case.
            – Mark Stosberg
            May 8 '17 at 17:22







          • 1




            Thanks. I have removed the [Install] section from the service unit and changed the [Install] section in my timer to WantedBy=timers.target.
            – bitofagoob
            May 8 '17 at 17:34












          up vote
          9
          down vote



          accepted







          up vote
          9
          down vote



          accepted






          if myjob.service contains no [Install] block, then it is sufficient to just disable the timer. The timer was the only thing starting the .service file, so with the .timer disabled, nothing will start the .service file.



          Also remember to run systemctl --user stop myjob.timer. Disabling the timer prevents it from being started on the next boot, but it does not stop the timer currently running.






          share|improve this answer














          if myjob.service contains no [Install] block, then it is sufficient to just disable the timer. The timer was the only thing starting the .service file, so with the .timer disabled, nothing will start the .service file.



          Also remember to run systemctl --user stop myjob.timer. Disabling the timer prevents it from being started on the next boot, but it does not stop the timer currently running.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 21 at 14:33

























          answered May 8 '17 at 15:40









          Mark Stosberg

          3,6021023




          3,6021023











          • I have an [Install] block in each of my timer units. It has one entry, saying 'WantedBy=default.target'. I got this from the guides I followed. Can I just get rid of the [Install] block altogether?
            – bitofagoob
            May 8 '17 at 15:44






          • 1




            OK. I have read about the [Install] section and I think that WantedBy=default.target is just there to ensure that the unit, when enabled, is brought to life during any normal boot session (either multi-user or graphical). I will take Mark Stosberg's advice and disable only the timer unit. I will also mark his answer as the solution. Cheers Mark!
            – bitofagoob
            May 8 '17 at 15:54






          • 2




            You want the [Install] section on your timer units so they are started on boot. Usually WantedBy=timers.target. You only need an [Install] section for a service if you want the service to be started at boot time, which it sounds like you don't want in this case.
            – Mark Stosberg
            May 8 '17 at 17:22







          • 1




            Thanks. I have removed the [Install] section from the service unit and changed the [Install] section in my timer to WantedBy=timers.target.
            – bitofagoob
            May 8 '17 at 17:34
















          • I have an [Install] block in each of my timer units. It has one entry, saying 'WantedBy=default.target'. I got this from the guides I followed. Can I just get rid of the [Install] block altogether?
            – bitofagoob
            May 8 '17 at 15:44






          • 1




            OK. I have read about the [Install] section and I think that WantedBy=default.target is just there to ensure that the unit, when enabled, is brought to life during any normal boot session (either multi-user or graphical). I will take Mark Stosberg's advice and disable only the timer unit. I will also mark his answer as the solution. Cheers Mark!
            – bitofagoob
            May 8 '17 at 15:54






          • 2




            You want the [Install] section on your timer units so they are started on boot. Usually WantedBy=timers.target. You only need an [Install] section for a service if you want the service to be started at boot time, which it sounds like you don't want in this case.
            – Mark Stosberg
            May 8 '17 at 17:22







          • 1




            Thanks. I have removed the [Install] section from the service unit and changed the [Install] section in my timer to WantedBy=timers.target.
            – bitofagoob
            May 8 '17 at 17:34















          I have an [Install] block in each of my timer units. It has one entry, saying 'WantedBy=default.target'. I got this from the guides I followed. Can I just get rid of the [Install] block altogether?
          – bitofagoob
          May 8 '17 at 15:44




          I have an [Install] block in each of my timer units. It has one entry, saying 'WantedBy=default.target'. I got this from the guides I followed. Can I just get rid of the [Install] block altogether?
          – bitofagoob
          May 8 '17 at 15:44




          1




          1




          OK. I have read about the [Install] section and I think that WantedBy=default.target is just there to ensure that the unit, when enabled, is brought to life during any normal boot session (either multi-user or graphical). I will take Mark Stosberg's advice and disable only the timer unit. I will also mark his answer as the solution. Cheers Mark!
          – bitofagoob
          May 8 '17 at 15:54




          OK. I have read about the [Install] section and I think that WantedBy=default.target is just there to ensure that the unit, when enabled, is brought to life during any normal boot session (either multi-user or graphical). I will take Mark Stosberg's advice and disable only the timer unit. I will also mark his answer as the solution. Cheers Mark!
          – bitofagoob
          May 8 '17 at 15:54




          2




          2




          You want the [Install] section on your timer units so they are started on boot. Usually WantedBy=timers.target. You only need an [Install] section for a service if you want the service to be started at boot time, which it sounds like you don't want in this case.
          – Mark Stosberg
          May 8 '17 at 17:22





          You want the [Install] section on your timer units so they are started on boot. Usually WantedBy=timers.target. You only need an [Install] section for a service if you want the service to be started at boot time, which it sounds like you don't want in this case.
          – Mark Stosberg
          May 8 '17 at 17:22





          1




          1




          Thanks. I have removed the [Install] section from the service unit and changed the [Install] section in my timer to WantedBy=timers.target.
          – bitofagoob
          May 8 '17 at 17:34




          Thanks. I have removed the [Install] section from the service unit and changed the [Install] section in my timer to WantedBy=timers.target.
          – bitofagoob
          May 8 '17 at 17:34

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f363728%2fwhich-is-the-correct-way-to-disable-a-systemd-timer-unit%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)