Cron Expressions for Node.js: node-cron, node-schedule, and More
Table of Contents
Node.js doesn't have a built-in cron scheduler, but several npm packages implement cron-syntax scheduling. The most popular are node-cron and node-schedule. Use our free cron expression generator to build your schedule, then plug it into whichever package you're using.
node-cron vs node-schedule — Which Should You Use?
| Feature | node-cron | node-schedule |
|---|---|---|
| Cron syntax | 6-field (with seconds) | Standard 5-field + optional seconds |
| npm weekly downloads | ~3M | ~2M |
| One-time scheduling | No | Yes (scheduleJob with Date) |
| Cancel a job | task.stop() | job.cancel() |
| Timezone support | Yes | Yes |
| Active maintenance | Yes | Yes |
For recurring jobs with cron-style intervals, either works. node-cron is slightly simpler for pure cron use. node-schedule is more versatile if you also need one-time scheduled events or more complex recurrence rules.
node-cron Syntax and Examples
Install: npm install node-cron
node-cron uses 6 fields (seconds first), unlike standard Unix cron:
const cron = require('node-cron');
// Every minute (standard 5-field also works in node-cron)
cron.schedule('* * * * *', () => {
console.log('Running every minute');
});
// Every day at 9 AM
cron.schedule('0 9 * * *', () => {
runDailyReport();
});
// Every weekday at 9 AM in New York timezone
cron.schedule('0 9 * * 1-5', () => {
sendMorningDigest();
}, { timezone: 'America/New_York' });
// Every 30 seconds using 6-field format
cron.schedule('*/30 * * * * *', () => {
checkHealth();
});
Sell Custom Apparel — We Handle Printing & Free Shipping
node-schedule Syntax and Examples
Install: npm install node-schedule
const schedule = require('node-schedule');
// Standard 5-field cron: every day at midnight
const job = schedule.scheduleJob('0 0 * * *', function() {
runNightlyCleanup();
});
// Recurrence rule object
const rule = new schedule.RecurrenceRule();
rule.dayOfWeek = [1, 2, 3, 4, 5]; // Monday-Friday
rule.hour = 9;
rule.minute = 0;
schedule.scheduleJob(rule, function() {
runWeekdayJob();
});
// Cancel a job
job.cancel();
Node.js Cron on Serverless and Vercel
Running node-cron in serverless functions (AWS Lambda, Vercel, Netlify Functions) doesn't work — serverless functions don't persist between invocations, so there's no long-running process to hold the scheduler.
For serverless Node.js scheduling:
- AWS Lambda: Use AWS EventBridge Scheduler to trigger your Lambda on a cron schedule. The Lambda handles the logic; EventBridge handles the timing.
- Vercel: Use Vercel Cron Jobs in your
vercel.json— they support standard cron expressions and trigger your API routes. - Netlify: Netlify Scheduled Functions use standard cron syntax to trigger serverless functions.
For traditional Node.js servers (Express, Fastify, Koa) running as a long-running process on a VPS or container, node-cron or node-schedule work well. The scheduler lives in the process and fires jobs as long as the server is running.
Try It Free — No Signup Required
Runs 100% in your browser. No account, no install, no limits.
Open Free Cron GeneratorFrequently Asked Questions
Does node-cron use 5-field or 6-field cron expressions?
node-cron supports both. By default it uses a 6-field format with seconds as the first field. Standard 5-field expressions (without seconds) also work and are treated as "at second 0" of the matched minute.
Can I use cron jobs in a Next.js or Vercel application?
Not with node-cron directly — Vercel functions are serverless and don't run long-lived processes. Instead, use Vercel Cron Jobs in your vercel.json file, which triggers your API routes on a cron schedule using standard cron syntax.
What happens to node-cron jobs when the Node.js process restarts?
They reset. node-cron jobs exist only in memory. If your process crashes or restarts, all scheduled jobs restart from scratch — jobs that were due to run during the downtime are not queued or recovered. For critical jobs that must not be missed, use a persistent scheduler like a cloud cron service.

