Skip to content

Node-CronA Lightweight Task Scheduler for Node.js

One line to your first scheduled task, with room to grow into timezones, background processes, events, and observability.

node-cron

From one line to production ​

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.

js
import cron from 'node-cron';

// Day one: run something every minute.
cron.schedule('* * * * *', () => {
  console.log('Hello from node-cron');
});

Later, the same task can run in a specific timezone, skip overlapping runs, report failures, and run in its own process, all without changing how you think about it:

js
import cron from 'node-cron';

const task = cron.schedule('0 3 * * *', './tasks/nightly-backup.js', {
  name: 'nightly-backup',
  timezone: 'America/Sao_Paulo',
  noOverlap: true,
});

task.on('execution:failed', (ctx) => {
  console.error('backup failed:', ctx.execution?.error);
});

Follow the journey in order, or jump straight to what you need:

  1. Quickstart: install and run your first task in five minutes.
  2. Cron Syntax: learn how to express when a task should run.
  3. Task Lifecycle & Status: start, stop, and inspect tasks at runtime.
  4. Scheduling Options: timezones, overlap prevention, limits, and jitter.
  5. Events & Observability: react to every moment in a task's life.
  6. Background Tasks: run jobs in isolated processes.
  7. Logging: route node-cron's output through your own logger.
  8. Cookbook: copy-paste recipes for common jobs.

Need more than cron?

🚀 Check out Sidequest.js, a distributed job runner for Node.js inspired by Oban and Sidekiq.

  • Supports retries, priorities, schedules, and uniqueness
  • Works with Postgres, MySQL, SQLite and MongoDB
  • Includes a clean web dashboard for real-time monitoring

Released in 2016 under the ISC License.