0

I want to set a cron job time: on the 2nd and 17th of each month and every 3 hours these days. And first time cron job running is 01 am. after periods: 04 am, 07 am, 10 am, 1 pm, 4 pm, 7pm, 10pm. Just 2 days.

For instance: 2 May and 17 May. 2 June and 17 June.... And 01 am, 04 am, 07 am, 10 am, 1 pm, 4 pm, 7pm, 10pm periods.

I tired this : 00 00 2-17 * * ? But not work as I wanted.

EDIT: is solved: 0 0 1,4,7,10,13,16,19,22 2,17 * *. top 2 digits: 0 0 => seconds and minutes. Since I need seconds, I added the leading zero.

  • 1
    I solved : with this site-> https://cronexpressiontogo.com/every-2-months : 0 1/3 1,17 * * – Ayshe Ayparcasi May 04 '23 at 13:17
  • Shouldn't `1,17` be `2,17`? – andrewJames May 04 '23 at 13:22
  • My leader says : 0 0 1,4,7,10,13,16,19 2,17 * * ? @andrewJames . they both mean the same thing? – Ayshe Ayparcasi May 04 '23 at 13:27
  • Your question says "_on the 2nd and 17th of each month_". Does the cron expression `0 1/3 1,17 * *` (the expression _you_ provided) do that? – andrewJames May 04 '23 at 13:35
  • How are you executing your cron expression? What `cron` tool are you using? One provided by a Linux system (using `crontab`)? Or maybe [Quartz](https://www.javadoc.io/doc/org.quartz-scheduler/quartz/latest/org/quartz/CronExpression.html) (given you mentioned Spring in your question's tags)? – andrewJames May 04 '23 at 13:55
  • `0 1-23/3 2,17 * *` [link](https://www.crondrive.com/test-cron-expression?utf8=%E2%9C%93&expression=0+1-23%2F3+2%2C17+*+*&time_zone=UTC&commit=Test) is equivalent to `0 1,4,7,10,13,16,19,22 2,17 * *` [link](https://www.crondrive.com/test-cron-expression?utf8=%E2%9C%93&expression=0+1-23%2F3+2%2C17+*+*&time_zone=UTC&commit=Test) – Ishan May 04 '23 at 14:34
  • @AysheAyparcasi, in your leader's cron `0 0 1,4,7,10,13,16,19 2,17 * *`, it is missing a run at 22:00, after 19:00. – Ishan May 04 '23 at 14:36
  • I realized later that it was missing. @Ishan. Thank you. I have tested and is working correctly. – Ayshe Ayparcasi May 05 '23 at 07:55
  • OK - but STS is just your IDE tool. What _scheduler_ are you using? What `cron` tool? – andrewJames May 05 '23 at 13:03

0 Answers0