Set a cron every certain hours between certain hours
up vote
53
down vote
favorite
How can I set a cron to run every 2 hours between 8 am and 5 pm for example? Is this possible?
cron
migrated from stackoverflow.com Apr 11 '12 at 23:53
This question came from our site for professional and enthusiast programmers.
add a comment |
up vote
53
down vote
favorite
How can I set a cron to run every 2 hours between 8 am and 5 pm for example? Is this possible?
cron
migrated from stackoverflow.com Apr 11 '12 at 23:53
This question came from our site for professional and enthusiast programmers.
9
please read the question, it's not in Google... it's not a normal every 2 hours cron, it's every 2 hours between 8 and 5...
– luqita
Apr 11 '12 at 17:41
5
I searched Google and it brought me here! Thanks for the question/answer it was exactly what I was looking for.
– bh5k
Nov 28 '12 at 16:51
add a comment |
up vote
53
down vote
favorite
up vote
53
down vote
favorite
How can I set a cron to run every 2 hours between 8 am and 5 pm for example? Is this possible?
cron
How can I set a cron to run every 2 hours between 8 am and 5 pm for example? Is this possible?
cron
cron
asked Apr 11 '12 at 17:31
luqita
376136
376136
migrated from stackoverflow.com Apr 11 '12 at 23:53
This question came from our site for professional and enthusiast programmers.
migrated from stackoverflow.com Apr 11 '12 at 23:53
This question came from our site for professional and enthusiast programmers.
9
please read the question, it's not in Google... it's not a normal every 2 hours cron, it's every 2 hours between 8 and 5...
– luqita
Apr 11 '12 at 17:41
5
I searched Google and it brought me here! Thanks for the question/answer it was exactly what I was looking for.
– bh5k
Nov 28 '12 at 16:51
add a comment |
9
please read the question, it's not in Google... it's not a normal every 2 hours cron, it's every 2 hours between 8 and 5...
– luqita
Apr 11 '12 at 17:41
5
I searched Google and it brought me here! Thanks for the question/answer it was exactly what I was looking for.
– bh5k
Nov 28 '12 at 16:51
9
9
please read the question, it's not in Google... it's not a normal every 2 hours cron, it's every 2 hours between 8 and 5...
– luqita
Apr 11 '12 at 17:41
please read the question, it's not in Google... it's not a normal every 2 hours cron, it's every 2 hours between 8 and 5...
– luqita
Apr 11 '12 at 17:41
5
5
I searched Google and it brought me here! Thanks for the question/answer it was exactly what I was looking for.
– bh5k
Nov 28 '12 at 16:51
I searched Google and it brought me here! Thanks for the question/answer it was exactly what I was looking for.
– bh5k
Nov 28 '12 at 16:51
add a comment |
2 Answers
2
active
oldest
votes
up vote
68
down vote
Actually, Alex's (former) solution will run every minute, every 2 hours between 8 am and 3pm.
The right solution is:
0 8-17/2 * * * /path/command
Or even:
0 8,10,12,14,16 * * * /path/command
Which of course looks less nice, but still does what requested...
Why is it considered to be between 8am and 3pm if it will run at 4pm?
– Aleksey
Nov 25 '16 at 13:04
@Aleksey, Alex's solution before being edited ran from 8am to 3pm, which is not what the OP wants and also that's the reason I added this answer of mine and made a comment of that, if you read everything carefully you should get it...
– DarkAjax
Nov 26 '16 at 22:06
add a comment |
up vote
5
down vote
0 8-17/2 * * * your_command.sh
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
68
down vote
Actually, Alex's (former) solution will run every minute, every 2 hours between 8 am and 3pm.
The right solution is:
0 8-17/2 * * * /path/command
Or even:
0 8,10,12,14,16 * * * /path/command
Which of course looks less nice, but still does what requested...
Why is it considered to be between 8am and 3pm if it will run at 4pm?
– Aleksey
Nov 25 '16 at 13:04
@Aleksey, Alex's solution before being edited ran from 8am to 3pm, which is not what the OP wants and also that's the reason I added this answer of mine and made a comment of that, if you read everything carefully you should get it...
– DarkAjax
Nov 26 '16 at 22:06
add a comment |
up vote
68
down vote
Actually, Alex's (former) solution will run every minute, every 2 hours between 8 am and 3pm.
The right solution is:
0 8-17/2 * * * /path/command
Or even:
0 8,10,12,14,16 * * * /path/command
Which of course looks less nice, but still does what requested...
Why is it considered to be between 8am and 3pm if it will run at 4pm?
– Aleksey
Nov 25 '16 at 13:04
@Aleksey, Alex's solution before being edited ran from 8am to 3pm, which is not what the OP wants and also that's the reason I added this answer of mine and made a comment of that, if you read everything carefully you should get it...
– DarkAjax
Nov 26 '16 at 22:06
add a comment |
up vote
68
down vote
up vote
68
down vote
Actually, Alex's (former) solution will run every minute, every 2 hours between 8 am and 3pm.
The right solution is:
0 8-17/2 * * * /path/command
Or even:
0 8,10,12,14,16 * * * /path/command
Which of course looks less nice, but still does what requested...
Actually, Alex's (former) solution will run every minute, every 2 hours between 8 am and 3pm.
The right solution is:
0 8-17/2 * * * /path/command
Or even:
0 8,10,12,14,16 * * * /path/command
Which of course looks less nice, but still does what requested...
edited Nov 21 at 2:50
Scott
15.5k113789
15.5k113789
answered Aug 27 '12 at 21:43
DarkAjax
881711
881711
Why is it considered to be between 8am and 3pm if it will run at 4pm?
– Aleksey
Nov 25 '16 at 13:04
@Aleksey, Alex's solution before being edited ran from 8am to 3pm, which is not what the OP wants and also that's the reason I added this answer of mine and made a comment of that, if you read everything carefully you should get it...
– DarkAjax
Nov 26 '16 at 22:06
add a comment |
Why is it considered to be between 8am and 3pm if it will run at 4pm?
– Aleksey
Nov 25 '16 at 13:04
@Aleksey, Alex's solution before being edited ran from 8am to 3pm, which is not what the OP wants and also that's the reason I added this answer of mine and made a comment of that, if you read everything carefully you should get it...
– DarkAjax
Nov 26 '16 at 22:06
Why is it considered to be between 8am and 3pm if it will run at 4pm?
– Aleksey
Nov 25 '16 at 13:04
Why is it considered to be between 8am and 3pm if it will run at 4pm?
– Aleksey
Nov 25 '16 at 13:04
@Aleksey, Alex's solution before being edited ran from 8am to 3pm, which is not what the OP wants and also that's the reason I added this answer of mine and made a comment of that, if you read everything carefully you should get it...
– DarkAjax
Nov 26 '16 at 22:06
@Aleksey, Alex's solution before being edited ran from 8am to 3pm, which is not what the OP wants and also that's the reason I added this answer of mine and made a comment of that, if you read everything carefully you should get it...
– DarkAjax
Nov 26 '16 at 22:06
add a comment |
up vote
5
down vote
0 8-17/2 * * * your_command.sh
add a comment |
up vote
5
down vote
0 8-17/2 * * * your_command.sh
add a comment |
up vote
5
down vote
up vote
5
down vote
0 8-17/2 * * * your_command.sh
0 8-17/2 * * * your_command.sh
edited Jul 17 '14 at 16:30
answered Apr 11 '12 at 17:47
Alex
256310
256310
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2fsuperuser.com%2fquestions%2f411406%2fset-a-cron-every-certain-hours-between-certain-hours%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
9
please read the question, it's not in Google... it's not a normal every 2 hours cron, it's every 2 hours between 8 and 5...
– luqita
Apr 11 '12 at 17:41
5
I searched Google and it brought me here! Thanks for the question/answer it was exactly what I was looking for.
– bh5k
Nov 28 '12 at 16:51