# gocron

> A Golang job scheduling package which lets you run Go functions at pre-determined intervals

Source: https://talira.ai/catalog/gocron-e8cq5atx
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [libraries / job scheduling](https://talira.ai/categories/libraries/job-scheduling), [languages / go](https://talira.ai/categories/languages/go)
- Licence: MIT[^3]
- Pricing: Free and open source[^3]
- Free tier: yes[^3]
- Self-hostable: yes[^1]
- Plugins: yes[^1]
- Backed by: [go-co-op](https://talira.ai/orgs/go-co-op.md)
- Sponsors: JetBrains, Sentry

gocron runs Go functions on a schedule inside your own process: fixed or random durations, crontab expressions, daily, weekly and monthly times, or one-off times. A scheduler hands due jobs to an executor that can keep a job from overlapping itself (singleton mode) and cap how many run at once. When several replicas run the same scheduler, a distributed elector lets only the elected leader run jobs, or a distributed locker locks each run to one instance; the go-co-op organization publishes lockers for GORM-backed SQL databases and [Redis](https://talira.ai/catalog/redis-v917j45s.md), an [etcd](https://talira.ai/catalog/etcd-zdq64wjj.md) elector and gocron-ui, a web dashboard for the jobs. The GORM locker keys each lock on the job's name and its scheduled time with a unique constraint, so a run that another instance already claimed is skipped. It started as a fork of jasonlvhit/gocron; v2 is the current major version.

## Links

- GitHub: https://github.com/go-co-op/gocron
- Docs: https://pkg.go.dev/github.com/go-co-op/gocron/v2

## Problems it solves

- run a Go function every night at 2am inside my service
- cron-style scheduled tasks in a Go program without the system crontab
- scaling my Go service out made every scheduled task fire on each copy
- make sure only one instance of my Go service runs each scheduled job
- a scheduled Go job takes longer than its interval and the runs pile up on each other
- limit how many scheduled jobs run at the same time in a Go service
- elect one leader among my Go replicas to run the scheduled tasks
- use our database to lock each scheduled run so only one server executes it
- test scheduled jobs in Go without waiting for real time to pass
- see and trigger my in-process scheduled jobs from a web dashboard
- get metrics on how long each scheduled job took and whether it failed

## Features

- duration, random duration, crontab, daily, weekly, monthly and one-time jobs
- intervals from the scheduled time or from the last completion
- singleton mode per job and a concurrency limit per scheduler, each rescheduling or queueing
- distributed elector: only the elected leader runs jobs (etcd elector published)
- distributed locker: each run locked to one instance (GORM and Redis lockers published)
- GORM locker keys locks on job name plus scheduled timestamp, with configurable precision and TTL cleanup
- event listeners on jobs and across the scheduler
- Monitor, MonitorStatus and SchedulerMonitor interfaces for metrics
- pluggable logger
- gomock mocks and a fake clock (WithClock) for tests
- gocron-ui web dashboard to monitor, trigger and manage jobs

## Limitations

- Doesn't coordinate runs across instances by default: each scheduler runs every job unless you add a distributed elector or locker[^1][^2]
- Doesn't synchronize run times across schedulers with a locker: clock skew between instances can leave one instance running most jobs[^2]

## Capabilities

- Takes plugins: plan not known

## Trust

Overall: 0.38 out of 1.
Signals: backing 0.45, extensibility 0.20.

- backed by go-co-op
- sponsored by JetBrains, Sentry
- has a plugin system

Warnings:

- GitHub activity not fetched yet

## Alternatives

- [River](https://talira.ai/catalog/river-2vkec0fw.md): Fast and reliable background jobs

## Sources

[^1]: https://github.com/go-co-op/gocron (checked 20 Nov 2026)
[^2]: https://github.com/go-co-op/gocron/blob/v2/distributed.go (checked 20 Nov 2026)
[^3]: https://github.com/go-co-op/gocron/blob/v2/LICENSE (checked 20 Nov 2026)
