Cron Expression to execute cron triggers for 12 hours of a day?
Asked Answered
W

2

11

I need a cron-expression (0 0/60 * * * ?) to fire application every 12 hours (twice a day).

Wilson answered 5/1, 2011 at 19:30 Comment(3)
for 12 hours a day as the title says, or every 12 hour as your post ?says (every 12 hour is twice a day, so, e.g. at .. 3 and 15. 0 3,15 * * *.)Journey
@nos. every 12 hours i.e. twice a day...Wilson
@nos. if your answer is 0 3,15 ***, can you please explain me how? Why 15? and also post the answer in answer box so that i can mark it as "answered".Wilson
J
18

Use e.g. 0 0 3,15 * * ? That'll run a job at 3am and 3pm. That's twice a day, with 12 hours between. You could use 0 0 0/12 * * ? which means every 12 hours. Here's some examples.

Journey answered 6/1, 2011 at 0:18 Comment(1)
Can you please add cron expression in brief because i want to do the same but with this i got the error like 'Unexpected end of expression.'Curd
V
3

Some examples that fit your criteria:

30 */12 * * *

runs at 00:30:00 and 12:30:00 each day

0 3-15/12 * * *

runs at 03:00:00 and 15:00:00 each day

23 4,16 * * *

runs at 04:23:00 and 16:23:00 each day

Villiers answered 17/2, 2011 at 0:57 Comment(1)
@webyildirim: in that case you should use two cron lines for the different times that execute the same command. There is no way to specify that in a single line.Villiers

© 2022 - 2024 — McMap. All rights reserved.