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.
Kind regards,
Angélica
Hi Angélica,
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dani,
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.