Is it possible to create a cron in AWS CloudWatch that runs every hour from 9:30 a.m. to 4:30 p.m. Monday through Friday?
In the documentation here, the closest example I have is this:
0/5, 8-17, ?, *, MON-FRI, * = Run every 5 minutes Monday through Friday between 8:00 am and 5:55 pm (UTC+0).
from the example above, where is it defined that it will end at "55 "minutes after "5" hours? Ignoring that, something like this occurs to me:
0/60, 9-16, ?, *, MON-FRI, *
but I'm not sure what it means or if it's correct, also it's not starting from 9:30 but from 9:00
I hope you can help me, thanks in advance
I used this calculator to verify and generate cron expressions.
In the example you provide 0/5, 8-17, ?, *, MON-FRI, *
0/5:- means it runs every five minutes starting at 00 minutes (00
minutes inclusive)
8-17:- means it runs between 8 and 17 hours with both 8 and 17
inclusive.
So For your use case:- 0, 10-16, ?, *, MON-FRI, *
(since hours between 9.30 - 4.30 are 10-16 and it only needs to run at the start of the hour which means 00 minutes)
Related
How can I run a cron job at 2am UTC at every Sunday and Wednesday on AWS.
0 2 * * SUN,WED *
The time is fine, just the days seem to be the wrong format (getting Parameter ScheduleExpression is not valid via serverless). But all resources I can find do only state ranges of days, how to select single ones?
Your cron should look like this:
0 2 ? * SUN,WED *
Or:
0 2 ? * 1,4 *
^
Day of month is wrong
Your issue is with the Day of month.
Check the result in EventBridge
Let's say I develop a ticket application that runs on windows. A given ticket has a validity of 3 hours. Now if I want to print a ticket on 28th of March 2020 (GMT+1, Germany) at 11 PM (23:00:00) it should be valid until 2 AM the next morning. (I manipulate my system time for testing)
Problem is, on the 29th DST-change happens: at 2 AM time will be set to 3 AM.
Due to DST the ticket is only valid until 1 AM (so technically only 2 hours), even though the actual time-leap happens later that day.
Here is what I do:
for the current time I use struct tm myTime;
myTime.tm_mday; \* = 28 *\
myTime.tm_hour; \* = 23 *\
struct tm newTime;
newTime.tm_mday = myTime.tm_mday; \* also done for remaining fields *\
newTime.tm_hour = myTime.tm_hour + 3; \* = 26 *\
no problem so far. On any other day the 26 hours will be converted to the following day 2 AM.
But if I call time_t result = _mktime64( newTime ); in this specific case, the resulting timestamp (e.g. 1585440205) will have mday = 29 and hour = 1 (when converted)
Is there another option, that calculates the time hour-precise, so that my ticket-validity doesn't lose one hour? (I assume _mktime64 recognizes the DST-change and manipulates all times for the day, no matter if they are before or after the actual time change at 2 AM)
I'm creating an AWS CloudWatch rule, using the Schedule Cron expression: 30 10 * * 2,5 *, namely - every Tuesday and Friday on 10:30 UTC.
However, AWS gives me
There was an error while saving rule Snapshot_EBS_disk.
Details: Parameter ScheduleExpression is not valid..
Any idea what's wrong with my expression?
One of day-of-month or day-of-week must be ?. So to make your cron expression valid you would use the following:
30 10 ? * 3,6 *
Also note that Tuesday and Friday are 3 and 6 respectively
Trying to setup a scheduled task in CF10 (Standard) to run every 15 minutes but only on Tuesdays. A cron created said this would do the job:
*/15 * * * 2
But that gives the error "An error occured scheduling the task.
Unexpected end of expression." I also tried
15 * * * 2
The notes say 6 or 7 space separated fields - what am I missing? Minute, hour, day of month, month, day of week is 5 fields.
The representation is in the below format:-
Seconds Minutes Hours Day-of-Month Month Day-of-Week Year (optional
field)
So, for a task to run every 15 minutes but only on Tuesdays, below is the CRON.
"0 0/15 * ? * TUE".
You can refer to the link below for more details:
http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/tutorial-lesson-06
I have a scheduled task that needs to run three times a day, on each weekday. The setup surrounding the task is Coldfusion, and it is in the Crontime format. It should run at 11:30, 15:45 and 18:30 server time.
For some reason the task is occasionally running on weekends, which it should not do.
Here are the three strings for each of the days:
0 30 11 ? * 1-5
0 45 15 ? * 1-5
0 30 18 ? * 1-5
Can anyone point out to me why the task is sometimes running on weekends? Is there a mistake in my string?
The Coldfusion crontime documentation can be found here:
According to This, 1 = Sunday.
Days-of-Week can be specified as values between 1 and 7 (1 = Sunday) or by using the strings SUN, MON, TUE, WED, THU, FRI and SAT.
Try replacing 1-5 with MON-FRI?
An example of a complete cron-expression is the string "0 0 12 ? * WED" - which means "every Wednesday at 12:00:00 pm".
Individual sub-expressions can contain ranges and/or lists. For example, the day of week field in the previous (which reads "WED") example could be replaced with "MON-FRI", "MON,WED,FRI", or even "MON-WED,SAT".