It runs a function on a cron expression inside your Node.js process. No dependencies, no database. Version 4 needs Node.js 20 or newer.
node-cron keeps its schedule in memory. A run that falls due while the process is down never happens, and v4 does not replay it.
Minute, hour, day of month, month, day of week, plus optional seconds first.
1. Every 5 minutes: */5 * * * *
2. Weekdays at 09:00: 0 9 * * 1-5
scheduled: false is now cron.createTask(). runOnInit and task.now() became task.execute(). The task-done event is now execution:finished.
Without the timezone option, the task uses the server's zone, often UTC. Pass an IANA name like America/Sao_Paulo or Etc/UTC.
A daily time inside the skipped spring-forward hour does not run that day. On fall-back, a repeated time fires once. Use Etc/UTC for fixed spacing.
noOverlap: true skips a run while the previous one is still going, and emits execution:overlap.
distributed: true plus a name runs each fire on one instance. Set NODE_CRON_RUN to true on one server, or add the Redis coordinator for failover.
One-off jobs at a set time, retries with backoff and work that must survive a restart belong in a queue like BullMQ or pg-boss.
A v3 to v4 migration table, a node-cron vs job queue comparison and a 7-point checklist before running it in production.
postgate.studio