Vcron
Bun

variable

cron

const cron: (path: string, schedule: CronWithAutocomplete, title: string) => Promise<void>

Register an OS-level cron job that runs a JavaScript/TypeScript module on a schedule.

The module must export a default object with a scheduled(controller) method, conforming to the Cloudflare Workers Cron Triggers API.

On Linux, registers with crontab. On macOS, registers with launchd. On Windows, registers with Task Scheduler.

Cron expression syntax (5 fields: minute hour day month weekday):

FieldValuesSpecial
Minute0-59* , - /
Hour0-23* , - /
Day of month1-31* , - /
Month1-12 or JAN-DEC* , - /
Day of week0-7 or SUN-SAT* , - /
  • 0 and 7 both mean Sunday in the weekday field.
  • Month/day names are case-insensitive (MON, Mon, Monday all work).
  • Predefined nicknames: @yearly, @annually, @monthly, @weekly, @daily, @midnight, @hourly.
  • When both day-of-month and day-of-week are specified (neither is *), the job runs when either field matches (POSIX cron behavior).
// Run every Monday at 2:30 AM
await Bun.cron("./worker.ts", "30 2 * * MON", "weekly-report");

// Run daily at midnight
await Bun.cron("./cleanup.ts", "@daily", "daily-cleanup");