Cron provides utilities for working with cron expressions and scheduled tasks.
Learn more about Mintlify
Enter your email to receive updates about new features and product releases.
API reference for Cron expressions and scheduling
Cron provides utilities for working with cron expressions and scheduled tasks.
interface Cron {
readonly _id: 'Cron'
}
const parse: (expression: string) => Either<CronError, Cron>
const make: (options: {
minutes?: string
hours?: string
days?: string
months?: string
weekdays?: string
}) => Cron
const next: (now: DateTime) => (self: Cron) => DateTime
const schedule: (cron: Cron) => Schedule<DateTime>
const match: (date: DateTime) => (self: Cron) => boolean
import { Cron, Effect, Schedule } from "effect"
const program = Effect.gen(function* () {
const cron = Cron.parse("0 9 * * MON-FRI").pipe(
Effect.orDie
)
const schedule = Cron.schedule(cron)
yield* Effect.repeat(
Effect.log("Running daily task"),
schedule
)
})