0

I am new to cron expression. I want to write cron expression for Everyday 1.00 AM and Everyday 2.00 AM ? . How can i write cron expression?

Thanks

Basit
  • 8,426
  • 46
  • 116
  • 196

1 Answers1

0

If I don't mistake it should be like:

0 1  *   *   *    command

0 2  *   *   *    command
Jevgeni Smirnov
  • 3,787
  • 5
  • 33
  • 50
  • `0 0 * * *` refer to 1.00 Am and `0 1 * * *` refer to 2.00 AM, is it ? – Basit Jan 25 '13 at 08:11
  • Oops, sorry. Edited my answer. – Jevgeni Smirnov Jan 25 '13 at 08:13
  • I am new so please correct me if i am wrong, The first `0` represents `seconds`. Then second `1` represents `minutes` and then `hours`, `day of month`, `month`, `day of week` and then optional `year`. Shouldn't be it like `0 0 1 ? * *` for `everyday 1 A.m` and `0 0 2 ? **` for `everyday 2.00 pm`? am i right? Can you tell me please what does `* and ?` represent ? Thanks – Basit Jan 25 '13 at 08:20
  • @Basit, everything is right, except that there is no seconds. So the first is minutes and the second is hour. Then day of month, month, day of week. Seems there is no year. – Jevgeni Smirnov Jan 25 '13 at 08:40
  • check this link to know more about cron expressions http://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm – Rohit S Jan 25 '13 at 08:57
  • @ Jevgeni Smirnov sorry :) but you mean `0 0 1 ? * *` and `0 0 2 ? * *` are correct expressions for every day 1 a.m and every day 2 a.m respectively ? – Basit Jan 25 '13 at 09:02
  • @Basit, lets sayi in this way: 5 symbols would be enough. So for every day at `1.00` and `2.00` AM `0 1 * * *` and `0 2 * * *` would be enough – Jevgeni Smirnov Jan 25 '13 at 10:14