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

Clash Royale CLAN TAG#URR8PPP
up vote
13
down vote
favorite
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
add a comment |Â
up vote
13
down vote
favorite
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
add a comment |Â
up vote
13
down vote
favorite
up vote
13
down vote
favorite
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
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
systemd systemd-timer
asked May 8 '17 at 15:13
bitofagoob
455417
455417
add a comment |Â
add a comment |Â
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.
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. UsuallyWantedBy=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
add a comment |Â
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.
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. UsuallyWantedBy=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
add a comment |Â
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.
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. UsuallyWantedBy=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
add a comment |Â
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.
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.
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. UsuallyWantedBy=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
add a comment |Â
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. UsuallyWantedBy=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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password