I currently have the CRON expression for an automation that runs every two hours as follows:
0 0 0/2 ? * MON-FRI
However, due to the time zone distribution of my team, we'd like to tighten the period of this automation to exclude time around the weekend. I understand that the expression as written currently will start at 12:00am (midnight) UTC on Monday and last run will be around 10:00pm UTC on Friday. I'd like to modify it so that it insteads starts at 8am on Monday and then runs continuously every two hours until 6pm on Friday. Is this possible to do in a single expression?
In the worst case I think I'd split it into three expressions: one for Monday to start late, one for Tuesday through Thursday continuously, and one for Friday to end early, though this is less than ideal since it would result in extra work any time we would need to make changes in the future.
Hello @Dani Sill,
Welcome to the Atlassian Community!
Thank you for sharing the details.
Checking the documentation and also some websites that help with building CRON expressions, I believe that the one that fits your requirements would be:
0 0 8,10,12,14,16,18 ? * MON-FRI *
I used this one and here are the results of the next execution dates:
Please, take your time to test and let us know how it goes.
Your example would miss times that I would want the job to run, for example, I would want these times that are missing from your screenshot:
Mon Jul 05 20:00:00 UTC 2021
Mon Jul 05 22:00:00 UTC 2021
Tue Jul 06 00:00:00 UTC 2021
Tue Jul 06 02:00:00 UTC 2021
Tue Jul 06 04:00:00 UTC 2021
Tue Jul 06 06:00:00 UTC 2021
I’m sorry for the misunderstanding, I thought you needed the automation to run from 8 am to 6 pm every day.
We checked here and found out that it’s not possible to do what you need with only one rule, it will be necessary to use three.
The first one will work for Mondays, it will start at 08:00 and end at 22:00:
0 0 8/2 ? * MON *
The second one will start at midnight (Tuesday) and it will end at 22:00 on Thursday:
0 0 0/2 ? * TUE,WED,THU *
The last one will start at midnight (Friday) and end at 18:00 on Friday as well:
0 0 0-18/2 ? * FRI *
Hope this helps!
Hello Community! Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events