All posts

August 20, 2026 7 min read

node-cron vs node-schedule in production: what nobody tells you

node-cron and node-schedule both schedule jobs. Neither monitors them. Here's an honest comparison of both libraries for production use — and how to add the monitoring layer both are missing.


node-cron and node-schedule are the two most widely used JavaScript scheduling libraries. Between them they have tens of millions of weekly npm downloads. Most developers choose one, wire up their jobs, and ship to production without thinking carefully about what happens when something goes wrong.

Here's what neither library's documentation prominently covers: every job failure is silent by default. If your scheduled function throws an unhandled exception, node-cron logs it to stderr and continues. node-schedule fires an error event that goes nowhere unless you've attached a listener. If the Node.js process itself crashes, all scheduled jobs stop. No alert fires in either case.

This post compares the two libraries honestly for production use, then covers the monitoring layer both libraries are missing.


node-cron

node-cron is the simpler of the two. It takes a cron expression and a function, runs the function on schedule, and gets out of the way. Its API surface is minimal: schedule(), validate(), and basic task controls (start, stop, destroy).

import cron from 'node-cron';

cron.schedule('0 2 * * *', async () => {
  await syncDatabase();
});

What it handles well: simple, fire-and-forget jobs with standard five or six-field cron expressions. Zero configuration overhead. The most downloaded scheduling library in the Node.js ecosystem for a reason.

Production limitations:

  • No overlap protection. If syncDatabase() takes longer than 24 hours, the next scheduled execution fires while the previous one is still running. You get concurrent executions with no built-in guard.
  • No maximum duration. A hung function runs forever. node-cron has no concept of a timeout.
  • No error boundary. An unhandled exception inside the scheduled function logs to stderr and is swallowed. The next execution fires as normal. You have no record of the failure unless you catch it yourself.
  • In-process only. The schedule disappears when the process restarts. On AWS Lambda, Vercel, or any serverless environment that doesn't maintain persistent processes, node-cron doesn't work at all.

node-schedule

node-schedule offers more flexibility. It supports cron syntax, JavaScript Date objects, and recurrence rules — which let you express schedules that cron syntax can't, like "every 20 minutes between 9am and 5pm on weekdays."

import schedule from 'node-schedule';

// Cron syntax
schedule.scheduleJob('0 2 * * *', async () => {
  await syncDatabase();
});

// Date-based
const date = new Date(2026, 11, 21, 5, 30, 0);
schedule.scheduleJob(date, () => {
  console.log('Ran once at the specified time');
});

// Recurrence rule
const rule = new schedule.RecurrenceRule();
rule.dayOfWeek = [1, 2, 3, 4, 5]; // Weekdays only
rule.hour = 9;
rule.minute = 0;
schedule.scheduleJob(rule, () => {
  sendWeekdayReport();
});

What it handles well: complex scheduling scenarios that cron syntax doesn't express cleanly. Cancellable jobs (the scheduleJob return value has a cancel() method). Timezone support via the tz option.

Production limitations:

  • Same in-process constraint as node-cron. The schedule vanishes on process restart.
  • Same overlap and timeout gaps — no built-in protection against concurrent executions or runaway jobs.
  • Same silent failure behaviour — errors in scheduled functions are emitted as error events on the job object, which go nowhere unless you attach a listener:
const job = schedule.scheduleJob('0 2 * * *', async () => {
  await syncDatabase();
});

// Without this, errors are silently swallowed:
job.on('error', (err) => {
  console.error('Scheduled job failed:', err);
});

Most codebases I've seen don't attach this listener.


The monitoring layer both libraries are missing

Both node-cron and node-schedule are schedulers. They fire functions. They are not monitors. They don't know when a function should have run but didn't — because if the process is down, they're down with it.

The monitoring gap has three components:

Missed run detection. If the Node.js process crashes at 1:59am and your job is scheduled for 2:00am, neither library knows the job was supposed to run. An external monitoring service that knows your schedule and watches for a ping can fire an alert when the expected execution doesn't happen.

Hung job detection. Neither library has a maximum duration concept. A function that runs for six hours looks identical to one that runs for six seconds from the scheduler's perspective. An external monitor that receives a start ping but no success ping within a configured threshold can fire an alert.

Silent failure detection. A function that runs to completion without throwing but produces no useful output looks like a success to both libraries. An external monitor that receives metadata attached to the success ping can evaluate the output against alert rules you define.

Here's the complete monitoring pattern for node-cron:

import cron from 'node-cron';
import { CrontifyMonitor } from '@crontify/sdk';

const syncMonitor = new CrontifyMonitor({
  apiKey: process.env.CRONTIFY_API_KEY!,
  monitorId: 'mon_abc123',
});

const reportMonitor = new CrontifyMonitor({
  apiKey: process.env.CRONTIFY_API_KEY!,
  monitorId: 'mon_def456',
});

// Nightly sync — monitored
cron.schedule('0 2 * * *', async () => {
  await syncMonitor.wrap(async () => {
    const result = await syncDatabase();
    return {
      meta: {
        rows_synced: result.count,
        duration_ms: result.durationMs,
      }
    };
  });
});

// Daily report — monitored
cron.schedule('0 6 * * *', async () => {
  await reportMonitor.wrap(async () => {
    const report = await generateReport();
    return {
      meta: {
        rows_in_report: report.rowCount,
        recipients: report.recipients,
      }
    };
  });
});

The same pattern works identically with node-schedule — replace cron.schedule() with schedule.scheduleJob(). The monitoring SDK is library-agnostic.

wrap() sends a start ping before executing, a success ping with the returned metadata when the function completes, and a fail ping with the error message and stack trace if it throws.


Overlap protection

Both libraries have the same overlap gap. Here's a Redis-based lock that prevents concurrent executions regardless of which scheduler you're using:

import { createClient } from 'redis';

const redis = createClient({ url: process.env.REDIS_URL });

async function withLock<T>(
  key: string,
  ttlMs: number,
  fn: () => Promise<T>
): Promise<T | null> {
  const acquired = await redis.set(key, '1', {
    NX: true,
    PX: ttlMs,
  });

  if (!acquired) {
    console.log(`Lock ${key} already held — skipping this execution`);
    return null;
  }

  try {
    return await fn();
  } finally {
    await redis.del(key);
  }
}

// Usage with node-cron and monitoring
cron.schedule('0 2 * * *', async () => {
  await syncMonitor.wrap(async () => {
    const result = await withLock(
      'job:nightly-sync',
      30 * 60 * 1000, // 30 minute TTL
      () => syncDatabase()
    );

    return result
      ? { meta: { rows_synced: result.count } }
      : { meta: { rows_synced: -1 } }; // -1 signals a skipped execution
  });
});

In Crontify, define a rule: rows_synced eq -1 → fire alert (execution was skipped due to overlap). This surfaces the overlap condition as a monitoring event rather than a silent skip.


Which library to choose

Choose node-cron if your scheduling needs are simple cron expressions and you want the most widely adopted, minimal-API option. The ecosystem support is broader and most tutorials assume it.

Choose node-schedule if you need date-based scheduling, complex recurrence rules, or per-job timezone configuration. The additional API surface is worth it when you actually need what it offers.

Either way, add external monitoring. The choice of scheduling library is much less important than adding the monitoring layer both libraries are missing. A missed run, a hung job, or a silent failure has the same consequences regardless of which scheduler fired the function.

Crontify is free for up to 5 monitors — no credit card required. The SDK is zero-dependency TypeScript, compatible with node-cron, node-schedule, and any other scheduling library.


Start monitoring your scheduled jobs

Free plan includes 5 monitors. No credit card required. Up and running in under 5 minutes.

Get started free →