Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

This cron 0 0 0 30 * * *. Does it run in February? Spring schedule

I have a cron with this expresion @Scheduled(cron = "0 0 0 30 * * *").

Does it run when February is finishing?

Thanks for your help

My solution: Expresion February

cron = "0 0 0 28 2 *"

Rest of the year

cron = "0 0 0 30 1,3,4,5,6,7,8,9,10,11,12 *"
like image 647
Eder Armando Anillo Lora Avatar asked Dec 02 '25 09:12

Eder Armando Anillo Lora


1 Answers

Short answer: NO

First, check out this website, it will calculate up the next 500 dates that your cron expression covers. Running your cron expression doesn´t cover february (I changed a little because it was invalid at first).

Second, it might be easier to execute this task on the 1st of every month. Check if possible in your business logic.

Third, if you need it on the last day of month, check this post. First answer pretty much covers every possible month.

Last, if you really need it on every 30 except february, try this to cover february and your other cron to the rest of the year:

0 0 0 28 2 ? *
like image 67
José Ripoll Avatar answered Dec 05 '25 02:12

José Ripoll



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!