node-cron
Job scheduling for Node.js with overlap prevention and distributed coordination.
3. Used by agents' projects
Dependency in 38 public GitHub projects set up for AI coding agents that we scanned (0.6%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
nodecron.com/llms.txtFrom the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What node-cron does
node-cron is a zero-dependency, in-process cron scheduler. It adds one-flag overlap skipping, one-instance-per-fire coordination across replicas, and forked background tasks, and its own docs say plainly that it does not persist state and is not a job queue.
node-cron popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How node-cron is used
- node-cron is a dependency in 38 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (0.8% of the 4,867 JavaScript/TypeScript ones), #3 of 48 in jobs, queues and workflows.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 194; those are left out of every share on this page.
- The most used alternative in our scan is Croner (45 projects).
- Projects that use it most often also use dotenv (86.8%), uuid (55.3%), Express (55.3%).
By coding agent
Often used with
node-cron in practice
Strengths
Set <code>noOverlap: true</code> and a tick that fires while the previous run is still active is skipped, not stacked. The site describes it as needing no custom locking. Skipped runs emit <code>execution:overlap</code>.
With <code>distributed: true</code>, each scheduled fire runs on one instance. By default this uses an env-var flag (<code>NODE_CRON_RUN</code>, per the docs index). A Redis coordinator is available for high availability.
Pass a path such as <code>'./tasks/backup.js'</code> instead of a function, and node-cron runs the job in a separate forked process. Background tasks use the same task interface and events as inline ones.
Expressions accept an optional seconds field, plus <code>L</code>, <code>L-n</code>, <code>W</code>, <code>#</code> and <code>?</code>. Inverted ranges such as <code>22-2</code> wrap around the field.
Watch out for
Schedules live in process memory. The maintainers say node-cron does not persist state, and they recommend a queue or workflow engine when you need exactly-once guarantees across crashes.
v4 removed <code>recoverMissedExecutions</code>. A missed run only emits <code>execution:missed</code> and logs a warning. Any catch-up logic is yours to write.
Background tasks fork a helper file from <code>node_modules</code>. If you bundle without marking node-cron external, the fork fails with <code>Cannot find module '.../daemon.js'</code>. Inline function tasks are not affected.
Control and inspect a scheduled task
const task = cron.schedule('0 3 * * *', doWork, {
name: 'nightly-backup',
timezone: 'America/Sao_Paulo',
});
task.stop(); // pause
task.start(); // resume
task.destroy(); // remove permanently
task.getStatus(); // 'stopped' | 'idle' | 'running' | 'destroyed'
task.getNextRun(); // next scheduled Date, or null
task.lastRun(); // { date, result } or { date, error }, or nullMore about node-cron
Funding
- GitHub Sponsors: https://github.com/node-cron
- Open Collective: https://opencollective.com/node-cron
Packages around it
- dotenv: Loads .env files
- axios: HTTP client
- express: Web server framework
- ts-node: Runs TypeScript in Node
- @solana/spl-token: Solana token program client
- cors: CORS middleware
More in Jobs, queues and workflows
Alternatives
node-cron This page
JavaScript cron expression parser and task scheduler with no dependencies, for all environments.
Fast, reliable Redis-backed queue for jobs and messages in Node.js.
Runs cron jobs in Node.js.
Get started
Install it.
npm install node-cronRules for your agent
## node-cron
- Target v4: it requires Node.js 20+. Use `task.execute()`, not `task.now()`. Do not pass `scheduled`, `runOnInit` or `recoverMissedExecutions`; v4 removed them.
- `cron.schedule` starts the task immediately. When the task should start later, use `cron.createTask` with the same arguments and call `.start()` yourself.
- Listen for `execution:finished` and `execution:failed`, not the v3 `task-done` event. Listeners receive a `TaskContext`.
- Add `noOverlap: true` for jobs that can outlast their interval. Add `distributed: true` plus a `name` when the app runs on several instances.
- For background tasks (a file path instead of a function) in a bundled app, mark node-cron as external (`--external:node-cron`). The `logger` option is not supported for background tasks.
- Use `timezone: 'UTC'` when a fixed interval must keep firing across DST changes.
- Do not use node-cron when you need durable queues, retries, or exactly-once runs across crashes. It does not persist state.