upstart run script between particular time
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I would like to run a script between two hours using upstart:
- start at: 9h00
- stop at: 23h30
This is my upstart:
author "bakka"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
script
H_BEGIN="905"
H_END="2330"
H_NOW=$(date +%k%M)
if [[ ${H_NOW} -gt ${H_BEGIN} && ${H_NOW} -lt ${H_END} ]]; then
exec my_python_script
fi
end script
but it doesn't seems to take the condition, even if i remove the "start on runlevel [2345]"
i've already take a look here: http://upstart.ubuntu.com/faq.html#replace-cron
You'd be able to have a service only running between particular times,
or on particular days, etc.
Blockquote
But it's not made very clear.
If somebody knows how to specify a between time to launch something by using upstart, it would be nice.
upstart
add a comment |
I would like to run a script between two hours using upstart:
- start at: 9h00
- stop at: 23h30
This is my upstart:
author "bakka"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
script
H_BEGIN="905"
H_END="2330"
H_NOW=$(date +%k%M)
if [[ ${H_NOW} -gt ${H_BEGIN} && ${H_NOW} -lt ${H_END} ]]; then
exec my_python_script
fi
end script
but it doesn't seems to take the condition, even if i remove the "start on runlevel [2345]"
i've already take a look here: http://upstart.ubuntu.com/faq.html#replace-cron
You'd be able to have a service only running between particular times,
or on particular days, etc.
Blockquote
But it's not made very clear.
If somebody knows how to specify a between time to launch something by using upstart, it would be nice.
upstart
add a comment |
I would like to run a script between two hours using upstart:
- start at: 9h00
- stop at: 23h30
This is my upstart:
author "bakka"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
script
H_BEGIN="905"
H_END="2330"
H_NOW=$(date +%k%M)
if [[ ${H_NOW} -gt ${H_BEGIN} && ${H_NOW} -lt ${H_END} ]]; then
exec my_python_script
fi
end script
but it doesn't seems to take the condition, even if i remove the "start on runlevel [2345]"
i've already take a look here: http://upstart.ubuntu.com/faq.html#replace-cron
You'd be able to have a service only running between particular times,
or on particular days, etc.
Blockquote
But it's not made very clear.
If somebody knows how to specify a between time to launch something by using upstart, it would be nice.
upstart
I would like to run a script between two hours using upstart:
- start at: 9h00
- stop at: 23h30
This is my upstart:
author "bakka"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
script
H_BEGIN="905"
H_END="2330"
H_NOW=$(date +%k%M)
if [[ ${H_NOW} -gt ${H_BEGIN} && ${H_NOW} -lt ${H_END} ]]; then
exec my_python_script
fi
end script
but it doesn't seems to take the condition, even if i remove the "start on runlevel [2345]"
i've already take a look here: http://upstart.ubuntu.com/faq.html#replace-cron
You'd be able to have a service only running between particular times,
or on particular days, etc.
Blockquote
But it's not made very clear.
If somebody knows how to specify a between time to launch something by using upstart, it would be nice.
upstart
upstart
asked Nov 15 '18 at 14:00
BakkaBakka
84
84
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
This was never implemented as a part of upstart. I would suggest using the very simple tool snooze in conjunction with upstart. This is how I run my cron.{hourly,daily,weekly,monthly} scripts on void linux.
For your particular case, starting the job at 9:00 and stopping it at 23:30, you would use three jobs like this:
description "start my service if it is after 9:00 but before 23:30"
emits start-myservice
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec snooze -H9 -s870 -- initctl emit start-myservice
description "stop my service if it is after 23:30 but before 9:00"
emits stop-myservice
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec snooze -H23 -M30 -s570 -- initctl emit stop-myservice
description "my service"
start on start-myservice
stop on stop-myservice
respawn
exec my_python_script
Thanks a lot, this do what i want nicely
– Bakka
Nov 27 '18 at 10:03
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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',
autoActivateHeartbeat: false,
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
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53321134%2fupstart-run-script-between-particular-time%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This was never implemented as a part of upstart. I would suggest using the very simple tool snooze in conjunction with upstart. This is how I run my cron.{hourly,daily,weekly,monthly} scripts on void linux.
For your particular case, starting the job at 9:00 and stopping it at 23:30, you would use three jobs like this:
description "start my service if it is after 9:00 but before 23:30"
emits start-myservice
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec snooze -H9 -s870 -- initctl emit start-myservice
description "stop my service if it is after 23:30 but before 9:00"
emits stop-myservice
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec snooze -H23 -M30 -s570 -- initctl emit stop-myservice
description "my service"
start on start-myservice
stop on stop-myservice
respawn
exec my_python_script
Thanks a lot, this do what i want nicely
– Bakka
Nov 27 '18 at 10:03
add a comment |
This was never implemented as a part of upstart. I would suggest using the very simple tool snooze in conjunction with upstart. This is how I run my cron.{hourly,daily,weekly,monthly} scripts on void linux.
For your particular case, starting the job at 9:00 and stopping it at 23:30, you would use three jobs like this:
description "start my service if it is after 9:00 but before 23:30"
emits start-myservice
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec snooze -H9 -s870 -- initctl emit start-myservice
description "stop my service if it is after 23:30 but before 9:00"
emits stop-myservice
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec snooze -H23 -M30 -s570 -- initctl emit stop-myservice
description "my service"
start on start-myservice
stop on stop-myservice
respawn
exec my_python_script
Thanks a lot, this do what i want nicely
– Bakka
Nov 27 '18 at 10:03
add a comment |
This was never implemented as a part of upstart. I would suggest using the very simple tool snooze in conjunction with upstart. This is how I run my cron.{hourly,daily,weekly,monthly} scripts on void linux.
For your particular case, starting the job at 9:00 and stopping it at 23:30, you would use three jobs like this:
description "start my service if it is after 9:00 but before 23:30"
emits start-myservice
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec snooze -H9 -s870 -- initctl emit start-myservice
description "stop my service if it is after 23:30 but before 9:00"
emits stop-myservice
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec snooze -H23 -M30 -s570 -- initctl emit stop-myservice
description "my service"
start on start-myservice
stop on stop-myservice
respawn
exec my_python_script
This was never implemented as a part of upstart. I would suggest using the very simple tool snooze in conjunction with upstart. This is how I run my cron.{hourly,daily,weekly,monthly} scripts on void linux.
For your particular case, starting the job at 9:00 and stopping it at 23:30, you would use three jobs like this:
description "start my service if it is after 9:00 but before 23:30"
emits start-myservice
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec snooze -H9 -s870 -- initctl emit start-myservice
description "stop my service if it is after 23:30 but before 9:00"
emits stop-myservice
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec snooze -H23 -M30 -s570 -- initctl emit stop-myservice
description "my service"
start on start-myservice
stop on stop-myservice
respawn
exec my_python_script
answered Nov 24 '18 at 3:03
CameronNemoCameronNemo
57425
57425
Thanks a lot, this do what i want nicely
– Bakka
Nov 27 '18 at 10:03
add a comment |
Thanks a lot, this do what i want nicely
– Bakka
Nov 27 '18 at 10:03
Thanks a lot, this do what i want nicely
– Bakka
Nov 27 '18 at 10:03
Thanks a lot, this do what i want nicely
– Bakka
Nov 27 '18 at 10:03
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53321134%2fupstart-run-script-between-particular-time%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown