I have an AWS Lambda scheduled with chalice cron, in Python. Up until now, it's been
@app.schedule(chalice.Cron("0/30", "5-11", "*", "*", "?", "*"))
def foo(event):
And that works fine; it runs overnight (don't ask why). However, I want to set it up a second version to run on weekends:
@app.schedule(chalice.Cron("0/30", "1-4,12-15", "*", "*", "0,6", "*"))
def bar(event):
I tested this in a crontab checker, and it says that 0/30
is nonstandard and the final "*"
(for year) is wrong, but the rest should work in any cron engine. However, I get Parameter ScheduleExpression is not valid
anyway. Chalice docs ((1),(2)) are silent on what cron expressions are supported. Is this a feature Chalice Cron lacks, or should I look elsewhere for the source of the error?
The range was not the issue; the nonstandard day-of-week/day-of-month syntax was. The fix was
@app.schedule(chalice.Cron("0/30", "1-4,12-15", "*", "?", "0,6", "*"))
def bar(event):
Which makes AWS trigger the event on days 0 and 6 (Sun, Sat) regardless of which day of the month they fall on. Additionally, CloudWatch docs cover this information better than Chalice-specific docs.