11

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

STW
  • 44,917
  • 17
  • 105
  • 161
Jango
  • 5,375
  • 14
  • 57
  • 63
  • 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 * * *.) – nos Jan 05 '11 at 19:41
  • @nos. every 12 hours i.e. twice a day... – Jango Jan 05 '11 at 19:46
  • @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". – Jango Jan 05 '11 at 19:51

2 Answers2

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.

StackRover
  • 557
  • 5
  • 10
nos
  • 223,662
  • 58
  • 417
  • 506
  • 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.' – Bhavin Varsur Jun 17 '21 at 11:41
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

htaccess
  • 2,800
  • 26
  • 31
  • 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. – htaccess Apr 23 '14 at 08:33