# CronOptions

Options to configure a cron expression.

All fields are strings so you can use complex expressions. Absence of
a field implies '*' or '?', whichever one is appropriate.

Used as argument in: [Schedule.cron](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_autoscaling.Schedule.html#cron)

- Source: [`aws-autoscaling/lib/schedule.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-autoscaling/lib/schedule.ts#L66)
- Type last changed: v2.97.1 · 26 Sep 2023

## Example

TypeScript:

```ts
declare const autoScalingGroup: autoscaling.AutoScalingGroup;

autoScalingGroup.scaleOnSchedule('PrescaleInTheMorning', {
  schedule: autoscaling.Schedule.cron({ hour: '8', minute: '0' }),
  minCapacity: 20,
});

autoScalingGroup.scaleOnSchedule('AllowDownscalingAtNight', {
  schedule: autoscaling.Schedule.cron({ hour: '20', minute: '0' }),
  minCapacity: 1
});
```

Python:

```python
# auto_scaling_group: autoscaling.AutoScalingGroup

auto_scaling_group.scale_on_schedule("PrescaleInTheMorning",
    schedule=autoscaling.Schedule.cron(hour="8", minute="0"),
    min_capacity=20
)

auto_scaling_group.scale_on_schedule("AllowDownscalingAtNight",
    schedule=autoscaling.Schedule.cron(hour="20", minute="0"),
    min_capacity=1
)
```

Java:

```java
AutoScalingGroup autoScalingGroup;

autoScalingGroup.scaleOnSchedule("PrescaleInTheMorning", BasicScheduledActionProps.builder()
        .schedule(Schedule.cron(CronOptions.builder().hour("8").minute("0").build()))
        .minCapacity(20)
        .build());

autoScalingGroup.scaleOnSchedule("AllowDownscalingAtNight", BasicScheduledActionProps.builder()
        .schedule(Schedule.cron(CronOptions.builder().hour("20").minute("0").build()))
        .minCapacity(1)
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
AutoScalingGroup autoScalingGroup;

autoScalingGroup.ScaleOnSchedule("PrescaleInTheMorning", new BasicScheduledActionProps {
    Schedule = Schedule.Cron(new CronOptions { Hour = "8", Minute = "0" }),
    MinCapacity = 20
});

autoScalingGroup.ScaleOnSchedule("AllowDownscalingAtNight", new BasicScheduledActionProps {
    Schedule = Schedule.Cron(new CronOptions { Hour = "20", Minute = "0" }),
    MinCapacity = 1
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var autoScalingGroup AutoScalingGroup

autoScalingGroup.scaleOnSchedule(jsii.String("PrescaleInTheMorning"), &BasicScheduledActionProps{
	Schedule: autoscaling.Schedule_Cron(&CronOptions{
		Hour: jsii.String("8"),
		Minute: jsii.String("0"),
	}),
	MinCapacity: jsii.Number(20),
})

autoScalingGroup.scaleOnSchedule(jsii.String("AllowDownscalingAtNight"), &BasicScheduledActionProps{
	Schedule: autoscaling.Schedule_*Cron(&CronOptions{
		Hour: jsii.String("20"),
		Minute: jsii.String("0"),
	}),
	MinCapacity: jsii.Number(1),
})
```

## Properties

- `day`: string — The day of the month to run this rule at.

  **Default:** Every day of the month

- `hour`: string — The hour to run this rule at.

  **Default:** Every hour

- `minute`: string — The minute to run this rule at.

  **Default:** Every minute

- `month`: string — The month to run this rule at.

  **Default:** Every month

- `weekDay`: string — The day of the week to run this rule at.

  **Default:** Any day of the week
