Here is cron
expression I tried 0 0 0 */14 * ?
it is giving following schedules
Start Time:- Friday, September 8, 2017 1:25 AM
Next Scheduled :-
1. Friday, September 15, 2017 12:00 AM
2. Friday, September 29, 2017 12:00 AM
3. Sunday, October 1, 2017 12:00 AM
4. Sunday, October 15, 2017 12:00 AM
5. Sunday, October 29, 2017 12:00 AM
this expression is working for every 2 weeks in every month, but my requirement is it has to run for every 2 weeks, I mean after executing sept 29th
, nxt schedule should be October 13
but it is scheduling for October 1
Show activity on this post. Position 1 for minutes, allowed values are 1-60 position 2 for hours, allowed values are 1-24 position 3 for day of month ,allowed values are 1-31 position 4 for month ,allowed values are 1-12 position 5 for day of week ,allowed values are 1-7 or and the day starts at Monday.
As we already know that the pattern * */2 * * * executes the task for every 2 hour, similary can * * */2 * * execute the task for every 2 day (once in 2 days).
It is a wildcard for every part of the cron schedule expression. So * * * * * means every minute of every hour of every day of every month and every day of the week .
There is no direct cron
expression for every 2 weeks but I kept following cron
expression , which is similar to 2 weeks but not exactly for 2 weeks
cron for every 2weeks(on 1st and 15th of every month at 1:30AM) - 30 1 1,15 * *
Friday every two weeks:
0 0 * * Fri [ $(expr $(date +%W) \% 2) -eq 1 ] && /path/to/command
Found on: https://cron.help/every-2-weeks-on-friday
You need to specify a start day. Otherwise it's will always reset with the 1st day of the month. So this expression "0 0 0 23/14 OCT ? 2017" is every 2 weeks starting on October 23rd 2017
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With