A Golang job scheduling library that lets you run Go functions at pre-determined intervals using cron expressions, fixed durations, daily, weekly, monthly, or one-time schedules with support for distributed deployments.
Quick reference for job and scheduler options.
Options that configure individual jobs.
gocron.WithName("job-name")
gocron.WithTags("tag1", "tag2")gocron.WithSingletonMode(gocron.LimitModeReschedule)
gocron.WithIntervalFromCompletion()gocron.WithStartAt(gocron.WithStartImmediately())
gocron.WithStartAt(gocron.WithStartDateTime(time.Now().Add(time.Hour)))
gocron.WithLimitRunsTo(100)gocron.WithEventListeners(
gocron.BeforeJobRuns(func(uuid.UUID, string) { /* ... */ }),
gocron.AfterJobRuns(func(uuid.UUID, string) { /* ... */ }),
gocron.AfterJobRunsWithError(func(uuid.UUID, string, error) { /* ... */ }),
)gocron.WithDistributedJobLocker(locker)Options that configure the scheduler.
gocron.WithLimitConcurrentJobs(10, gocron.LimitModeReschedule)gocron.WithStopTimeout(30*time.Second)
gocron.WithGlobalJobOptions(
gocron.WithTags("global"),
)gocron.WithLogger(myLogger)
gocron.WithMonitor(myMonitor)
gocron.WithMonitorStatus(myStatusMonitor)
gocron.WithSchedulerMonitor(mySchedulerMonitor)gocron.WithDistributedElector(elector)
gocron.WithDistributedLocker(locker)loc, _ := time.LoadLocation("America/New_York")
gocron.WithLocation(loc)Install with Tessl CLI
npx tessl i tessl/golang-github-com-go-co-op-gocron-v2@2.19.1docs
api
examples
guides