I have a requirement to schedule a job in AWS CloudWatch events to be run once in every two days. I am using the below expression but getting a error Parameter ScheduleExpression is not valid
cron(0 0 */2 * ? *)
The below is the java code,
String cronExpression = "cron(0 0 */2 * ? *)"
PutRuleRequest request = new PutRuleRequest();
request
.withName(eventName)
.withRoleArn("arn:aws:iam::****")
.withScheduleExpression(cronExpression)
.withState(RuleState.ENABLED);
PutRuleResult result = cloudwatchConfig.cloudwatch().putRule(request);
CodePudding user response:
cron(0 0 1/2 * ? *)
You can verify here.
CodePudding user response:
If you put your syntax into cloudwatch, it too will report the same error you are seeing in the terraform,but fix it simple
cron(0 0 1-31/2 * ? *)
The explanation for each field is here: https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html
1-31 covers all the possible number of days in a month