1

I'm a little bit confused on the cron job documentation for cloudwatch events. My goal is to create a cron job that run every day at 9am, 5pm, and 11pm EST. Does this look correct or did I do it wrong? It seems like cloudwatch uses UTC military time so I tried to convert it to EST. I thought I was right, but I got the following error when trying to deploy cloudformation template via sam deploy

Parameter ScheduleExpression is not valid. (Service: AmazonCloudWatchEvents; Status Code: 400; Error Code: ValidationException

What is wrong with my cron job? I appreciate any help!

(SUN-SAT, 4,0,6)

UPDATED:

this below gets same error Parameter ScheduleExpression is not valid

 Events:
        CloudWatchEvent:
          Type: Schedule
          Properties:
            Schedule: cron(0 0 9,17,23 ? * * *)
      MemorySize: 128
      Timeout: 100
Andy
  • 185
  • 2
  • 6
  • 22
  • 1
    Note that many people say EST when they actually mean EST5EDT, which is also called America/New_York. The key difference is that genuine EST does not observe Daylight Saving Time (nor does UTC)... so bear these things in mind if you actually intend for these events to occur relative to local time that springs forward and falls back. 2300 on Sunday in New York is 0400 on Monday in UTC during winter but is 0300 on Monday in UTC during summer. – Michael - sqlbot Oct 22 '21 at 01:31

1 Answers1

2

You have to specify a value for all six required cron fields

This should satisfy all your requirements:

0 4,14,22 ? * * *

Generated using: https://www.freeformatter.com/cron-expression-generator-quartz.html

There are a lot of other cron generators you can find online.

Aman B
  • 2,276
  • 1
  • 18
  • 26
  • Since it's EST I want, wouldn't it be ```4,0,6``` instead of ```9,17,23```? – Andy Oct 22 '21 at 00:19
  • Yes you have to specify time in UTC, correct hours will be 4,14,22. You can convert timezones here https://www.worldtimebuddy.com/ – Aman B Oct 22 '21 at 00:29
  • see updated block in question above. Still something wrong with the format for cloudwatch event cron job. I get the same error. Perhaps cloudwatch event format for cron jobs are different from other cron jobs. This is the https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html – user6680 Oct 22 '21 at 00:34
  • Yep seems like the minimum precision is 1 minute so seconds are irrelevant here. Try `0 4,14,22 ? * * *` – Aman B Oct 22 '21 at 00:39