node-cron: Job Scheduling for Node.js | node-cron
Skip to content
Appearance
Node-CronJob Scheduling for Node.js<br>Schedule tasks with cron expressions. Prevent overlaps. Coordinate across instances. Run jobs in background processes. Zero dependencies.<br>Quickstart<br>Cron Syntax<br>API Reference
๐ Cron Scheduling<br>Schedule recurring tasks with standard cron expressions, from seconds through weekdays, with ranges, steps, lists, and named months/weekdays.
๐ก๏ธ Overlap Prevention<br>Long-running task still going when the next tick fires? noOverlap skips the run instead of stacking executions. One flag, no custom locking.
๐ Distributed Coordination<br>Running multiple replicas? Ensure each scheduled fire executes on exactly one instance, with env-var flags or a Redis coordinator.
โ๏ธ Background Processes<br>Move heavy jobs into isolated forked processes so a slow task never blocks your main event loop.
๐น๏ธ Runtime Control<br>Start, stop, destroy, and inspect tasks at runtime with a single consistent interface, plus lifecycle events for observability.
๐ชถ Zero Dependencies<br>Pure JavaScript, written in TypeScript. No native bindings, no external packages. Production-ready and tiny.
Are you an LLM? View /llms.txt for optimized Markdown documentation, or /llms-full.txt for full documentation bundle<br>From one line to production โ<br>These docs cover node-cron v4 .
node-cron is designed to grow with you. The same schedule call you write on day one is the one you keep; you just add options as your needs grow.<br>jsimport cron from 'node-cron';
// Day one: run something every minute.<br>cron.schedule('* * * * *', () => {<br>console.log('Hello from node-cron');<br>});<br>Later, the same task can run in a specific timezone, skip overlapping runs, coordinate across a fleet, and run in its own process:<br>jsimport cron from 'node-cron';
const task = cron.schedule('0 3 * * *', './tasks/nightly-backup.js', {<br>name: 'nightly-backup',<br>timezone: 'America/Sao_Paulo',<br>noOverlap: true,<br>distributed: true,<br>});
task.on('execution:failed', (ctx) => {<br>console.error('backup failed:', ctx.execution?.error);<br>});<br>When to use node-cron โ<br>Recurring jobs on a schedule (cron expressions with second-level precision)<br>Overlap prevention for long-running tasks<br>Coordinating scheduled tasks across multiple instances or replicas<br>Running heavy jobs in isolated background processes<br>Runtime control: start, stop, inspect, and observe tasks programmatically<br>Need more than cron?<br>Check out Sidequest.js , a distributed job runner for Node.js inspired by Oban and Sidekiq. Retries, priorities, schedules, uniqueness, and a web dashboard. Works with Postgres, MySQL, SQLite and MongoDB.
When to consider something else โ<br>Durable job queues with retries and priorities : use Sidequest, BullMQ, or Agenda<br>Persistent workflow orchestration : use Temporal or Inngest<br>Exactly-once guarantees across crashes : node-cron coordinates but does not persist state to a database; a queue or workflow engine is a better fit<br>Explore the docs โ<br>Follow the journey in order, or jump straight to what you need:<br>Quickstart : install and run your first task in five minutes.<br>Cron Syntax : learn how to express when a task should run.<br>Task Lifecycle & Status : start, stop, and inspect tasks at runtime.<br>Scheduling Options : timezones, overlap prevention, limits, and jitter.<br>Events & Observability : react to every moment in a task's life.<br>Background Tasks : run jobs in isolated processes.<br>Distributed Coordination : run a task on one instance per fire across a fleet.<br>Logging : route node-cron's output through your own logger.<br>Cookbook : copy-paste recipes for common jobs.<br>Common problems โ<br>How to prevent overlapping cron jobs<br>How to run cron jobs across multiple servers<br>How to run background jobs in Node.js