Hello,
Anyone can help me in how to create a Cron Job to run an automation exmple: every 6 hours at 10:00 AM from Monday to Friday
This article is not clear in the matter not helpful in how to achieve that: https://support.atlassian.com/jira-software-cloud/docs/manage-filters/
Cheers
Hi @Manoj Gangwar I did try something similar to your expression
0 10/6 * ? * MON-FRI but I am unsure whether this works based on https://support.atlassian.com/jira-software-cloud/docs/manage-filters/
Hi @Trudy Claspill every 6 hours like a normal Cron Job would do: 0 */6 * * Mon-Fri see https://crontab.guru/#0_*/6_*_*_Mon-Fri
You option to use ELSE IF is a nice solution but TBH I should not go through the ordeal in creating an automation to automate the Cron Jobs. My automations are enough complex, although your option is a feasible option should I not find a solution
You may test the below corn expression.
0 10/6 * ? * MON-FRI
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That expressions runs the automation every 6 minutes. Tested it
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Mario Coluzzi
Note that I have not tested this solution as that would require the passage of days of time.
I recommend you use a Schedule trigger like this:
That will start the rule running at 10 am (Los Angeles time) on Monday. The lower portion will run the rule every 6 hours.
You then need to add a condition to check the current time when the rule is running to see if it is during the time you don't want it to run. You didn't specify the latest time on Friday when the rule could run, but running every six hours means that it could run at 4 am, 10 am, 4 pm, and 10 pm, So let us say that the latest run can be the 10 pm run.
You'll need to use an IF-ELSE block so that you can apply multiple conditions to see if it is in the black out period and proceed with the rest of your rule if it is not.
In the first IF block you will check if the current day is Saturday or Sunday. If it is you don't want to run the rule.
The smart value to extract the day of week from the current time, with a conversion to relevant timezone, is:
{{now.convertToTimeZone("America/Los_Angeles").format("EEE")}}
In this case you don't want to run the main actions of the rule, but you must run some action. So add a Log action to log a message of your choice to the rule execution audit log.
Insert an Else-If to check for the next blackout condition; is it Monday and before 10 am.
The smart value to get the current hour of the day, with the conversion to the relevant timezone, is:
{{now.convertToTimeZone("America/Los_Angeles").format("k")}}
Again, since this is within the blackout you don't want to execute the main actions of your rule but you must execute some action. So add another Log action..
Lastly add the last Else after which you add the actions you want to execute for your automation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you clarify what you mean by your timing statement ?
Every 6 hours at 10 am Monday through Friday
Does that mean starting at 10 am each day a and ending at midnight each day, so that there would be 3 runs each day?
Or does that mean starting at 10 am on Monday and running every 6 hours continuously until a specific time on Friday?
My answer applies to the latter.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Trudy Claspill every 6 hours like a normal Cron Job would do: 0 */6 * * Mon-Fri see https://crontab.guru/#0_*/6_*_*_Mon-Fri
You option to use ELSE IF is a nice solution but TBH I should not go through the ordeal in creating an automation to automate the Cron Jobs. My automations are enough complex, although your option is a feasible option should I not find a solution
Hello @Mario Coluzzi
In your post you mentioned that you wanted the cron job to start at 10 am on Monday. That is the point I am trying to clarify.
Do you want the job to start at 10 am Monday and then run every 6 hours continuously through Friday?
Or do you want the first run of the job to be at 10 am each day, Monday through Friday?
*/6 for the Hours and MON-FRI for the days of week would start at 00:00 on Monday and run every six hour through 24:00 on Friday.
If you use 10/6 and MON-FRI then the job will start at 10:00 am each day and run every six hours until 23:00 that day.
If either of the two options above matches your needs then you don't need the If-Else blocks I described.
If you need something that starts at 10 am on Monday and then runs continuously every 6 hours through Friday then your options are:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I did put as @Manoj Gangwar said: 0 10/6 * ? * MON-FRI the automation runs every 6 minutes. I did test it. See logs timestamp dump below
It does not matter if the automation start running at 10:00 or at 15:20 or at 23:11 It has to run every 6 hours between weekdays of Mon to Fri.
If it can start at 00:01 even better
03/09/24, 10:22:29 pm
03/09/24, 10:17:56 pm
03/09/24, 10:14:01 pm
03/09/24, 10:00:31 pm
03/09/24, 09:54:29 pm
03/09/24, 09:48:25 pm
03/09/24, 09:42:44 pm
03/09/24, 09:36:29 pm
03/09/24, 09:28:54 pm
03/09/24, 09:22:55 pm
03/09/24, 09:17:17 pm
03/09/24, 09:11:15 pm
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The cron statement needs to include a Seconds element in the first position.
* 1 0/6 * * MON-FRI
Any Second, minute 1 of the hour, starting with hour 0 then every 6 hours, any day of the month, any month of the year, on the days of the week Monday through Friday.
Should work, but I haven't had a chance to test it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It does work! I put in place and it does the job.
Although Jira complains on wrong formatting, therefore the correct one is:
* 1 0/6 ? * MON-FRI
A bit tricky one but in the end we crack it
Thank you.
M
05/09/24, 12:04:28 am - Scheduled for - NO ACTIONS PERFORMED
04/09/24, 06:04:07 pm - Scheduled for - SUCCESS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Wonderful!
If our responses were helpful please consider clicking on the Accept Answer buttons to mark your Question as Solved.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.