# 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_events.Schedule.html#cron), [TriggerSchedule.cron](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_glue.TriggerSchedule.html#cron)

- Source: [`aws-events/lib/schedule.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-events/lib/schedule.ts#L96)

## Example

TypeScript:

```ts
import * as events from 'aws-cdk-lib/aws-events';
import * as targets from 'aws-cdk-lib/aws-events-targets';

declare const fn: lambda.Function;
const rule = new events.Rule(this, 'Schedule Rule', {
 schedule: events.Schedule.cron({ minute: '0', hour: '4' }),
});
rule.addTarget(new targets.LambdaFunction(fn));
```

Python:

```python
import aws_cdk.aws_events as events
import aws_cdk.aws_events_targets as targets

# fn: lambda.Function

rule = events.Rule(self, "Schedule Rule",
    schedule=events.Schedule.cron(minute="0", hour="4")
)
rule.add_target(targets.LambdaFunction(fn))
```

Java:

```java
import software.amazon.awscdk.services.events.*;
import software.amazon.awscdk.services.events.targets.*;

Function fn;

Rule rule = Rule.Builder.create(this, "Schedule Rule")
        .schedule(Schedule.cron(CronOptions.builder().minute("0").hour("4").build()))
        .build();
rule.addTarget(new LambdaFunction(fn));
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Events;
using Amazon.CDK.AWS.Events.Targets;

Function fn;

var rule = new Rule(this, "Schedule Rule", new RuleProps {
    Schedule = Schedule.Cron(new CronOptions { Minute = "0", Hour = "4" })
});
rule.AddTarget(new LambdaFunction(fn));
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"
import targets "github.com/aws/aws-cdk-go/awscdk"

var fn Function

rule := events.NewRule(this, jsii.String("Schedule Rule"), &RuleProps{
	Schedule: events.Schedule_Cron(&CronOptions{
		Minute: jsii.String("0"),
		Hour: jsii.String("4"),
	}),
})
rule.AddTarget(targets.NewLambdaFunction(fn))
```

## 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

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

  **Default:** Every year
