cron() expression has the following syntax in Serverless framework:
cron(Minutes Hours Day-of-Month Month Day-of-Week Year)
Please note that all six fields are required.
From the syntax above, you can see that the
cron() expression allows you to specify one of the following two options to schedule the cron to run on specific days:
The wildcards have the following meaning/uses:
,— to specify multiple values (e.g.
-— to specify ranges (e.g.
*— to include all values;
?— to use one or other between Day-of-Month and Day-of-Week fields;
/— to specify increments;
L— to specify last day of month or week;
W— to specify weekday in the Day-of-month field;
#— to specify a certain day of the week within a month (e.g.
3#1which refers to first Tuesday of the month).
Please note that:
You cannot use multiple expressions in the Day-of-Week field when you're using "
#" character. You may only define one expression in such a case;
You cannot use the
*(asterisk) wildcard for both, "Day-of-Month" and "Day-of-Week" fields in the same
cron()expression. If the expression you're using contains
*for both fields, then you must replace one of them with
You can learn more about wildcards and scheduled events in the official AWS CloudWatch Scheduled Events doc.
# Run at 6:00 pm (UTC) every Monday through Friday cron(0 18 ? * MON-FRI *) # Run at 8:00 am (UTC) every 1st day of the month cron(0 8 1 * ? *)
Hope you found this post useful. It was published . Please show your love and support by sharing this post.