restart systemd service within a timeframe
up vote
0
down vote
favorite
I have systemd unit file, I know it can be restarted on failure by providing parameters, like :
Restart=always
RestartSec=90
It will restart after 90 seconds whenever it fails,
But, I want to restart only if system time is in between given time-frame, say between 08:00 and 17:00, only then restart.
Is there way to do this via systemd ?
systemd systemd-timer
add a comment |
up vote
0
down vote
favorite
I have systemd unit file, I know it can be restarted on failure by providing parameters, like :
Restart=always
RestartSec=90
It will restart after 90 seconds whenever it fails,
But, I want to restart only if system time is in between given time-frame, say between 08:00 and 17:00, only then restart.
Is there way to do this via systemd ?
systemd systemd-timer
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have systemd unit file, I know it can be restarted on failure by providing parameters, like :
Restart=always
RestartSec=90
It will restart after 90 seconds whenever it fails,
But, I want to restart only if system time is in between given time-frame, say between 08:00 and 17:00, only then restart.
Is there way to do this via systemd ?
systemd systemd-timer
I have systemd unit file, I know it can be restarted on failure by providing parameters, like :
Restart=always
RestartSec=90
It will restart after 90 seconds whenever it fails,
But, I want to restart only if system time is in between given time-frame, say between 08:00 and 17:00, only then restart.
Is there way to do this via systemd ?
systemd systemd-timer
systemd systemd-timer
asked 6 hours ago
mkmayank
41610
41610
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Directly in a service unit file with settings: no.
With a Heath Robinson mechanism: yes, as follows.
- Create two snippet files somewhere,
wibble-in-hours.conf
with these settings turned on andwibble-out-of-hours.conf
with these settings turned off. Don't forget the section heading. - At any given point,
/etc/systemd/system/wibble.service.d/restart.conf
is one or the other of these files. The systemd manual (q.v.) explains drop-in directories and snippet files. - Set up uschedule jobs, cron jobs, or whatever other mechanism you like, to swap the snippet files around at the appropriate times, invoke
systemctl daemon-reload
, and of course bring the service up if it has terminated during the out of hours period. (Be aware of masking, disabled services, and the fact that some operating systems stop services temporarily during package upgrades, all of which make the test of whether to start the service non-trivial.)
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Directly in a service unit file with settings: no.
With a Heath Robinson mechanism: yes, as follows.
- Create two snippet files somewhere,
wibble-in-hours.conf
with these settings turned on andwibble-out-of-hours.conf
with these settings turned off. Don't forget the section heading. - At any given point,
/etc/systemd/system/wibble.service.d/restart.conf
is one or the other of these files. The systemd manual (q.v.) explains drop-in directories and snippet files. - Set up uschedule jobs, cron jobs, or whatever other mechanism you like, to swap the snippet files around at the appropriate times, invoke
systemctl daemon-reload
, and of course bring the service up if it has terminated during the out of hours period. (Be aware of masking, disabled services, and the fact that some operating systems stop services temporarily during package upgrades, all of which make the test of whether to start the service non-trivial.)
add a comment |
up vote
0
down vote
Directly in a service unit file with settings: no.
With a Heath Robinson mechanism: yes, as follows.
- Create two snippet files somewhere,
wibble-in-hours.conf
with these settings turned on andwibble-out-of-hours.conf
with these settings turned off. Don't forget the section heading. - At any given point,
/etc/systemd/system/wibble.service.d/restart.conf
is one or the other of these files. The systemd manual (q.v.) explains drop-in directories and snippet files. - Set up uschedule jobs, cron jobs, or whatever other mechanism you like, to swap the snippet files around at the appropriate times, invoke
systemctl daemon-reload
, and of course bring the service up if it has terminated during the out of hours period. (Be aware of masking, disabled services, and the fact that some operating systems stop services temporarily during package upgrades, all of which make the test of whether to start the service non-trivial.)
add a comment |
up vote
0
down vote
up vote
0
down vote
Directly in a service unit file with settings: no.
With a Heath Robinson mechanism: yes, as follows.
- Create two snippet files somewhere,
wibble-in-hours.conf
with these settings turned on andwibble-out-of-hours.conf
with these settings turned off. Don't forget the section heading. - At any given point,
/etc/systemd/system/wibble.service.d/restart.conf
is one or the other of these files. The systemd manual (q.v.) explains drop-in directories and snippet files. - Set up uschedule jobs, cron jobs, or whatever other mechanism you like, to swap the snippet files around at the appropriate times, invoke
systemctl daemon-reload
, and of course bring the service up if it has terminated during the out of hours period. (Be aware of masking, disabled services, and the fact that some operating systems stop services temporarily during package upgrades, all of which make the test of whether to start the service non-trivial.)
Directly in a service unit file with settings: no.
With a Heath Robinson mechanism: yes, as follows.
- Create two snippet files somewhere,
wibble-in-hours.conf
with these settings turned on andwibble-out-of-hours.conf
with these settings turned off. Don't forget the section heading. - At any given point,
/etc/systemd/system/wibble.service.d/restart.conf
is one or the other of these files. The systemd manual (q.v.) explains drop-in directories and snippet files. - Set up uschedule jobs, cron jobs, or whatever other mechanism you like, to swap the snippet files around at the appropriate times, invoke
systemctl daemon-reload
, and of course bring the service up if it has terminated during the out of hours period. (Be aware of masking, disabled services, and the fact that some operating systems stop services temporarily during package upgrades, all of which make the test of whether to start the service non-trivial.)
answered 2 hours ago
JdeBP
31.4k466145
31.4k466145
add a comment |
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%2f481640%2frestart-systemd-service-within-a-timeframe%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