Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cron expression to run every day starting from a date

I need a cron expression which will fire every day at 12 pm starting from jan 25 2016. This is what I came up with:

0 0 12 25/1 * ? *

but after jan 31, the next firing time is feb 25.

Is there a cron expression expression for doing this? If not what can I use?

like image 573
Drunken Daddy Avatar asked Jan 22 '16 07:01

Drunken Daddy


1 Answers

Assuming that after January 25th you want to run this process forever after (i.e. 2032, when probably the server will be already substituted), I would do it with three expressions:

0 0 12 25-31 1 * 2016  command # Will run the last days of Jan 2016 after the 25th
0 0 12 * 2-12 * 2016   command # Will run the rest of the months of 2016
0 0 12 * * * 2017-2032 command # will run for every day of years 2017 and after.

I hope this helps.

like image 166
Jorge Torres Avatar answered Sep 19 '22 02:09

Jorge Torres