node-cron

A lightweight Node.js library for scheduling jobs on cron expressions, dates, or Luxon DateTimes, with built-in time zone support.

Library
npm
v4.4.0
8,948stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
87/100Excellent
Development Activity92
Maintenance84
Community72
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture82
Code Quality92
Innovation74
Learning Curve70

Cron (published to npm as cron) is a scheduling library for Node.js that runs functions or shell commands on a six-field cron expression, adding a seconds slot on top of the standard five-field Unix format. Jobs can also be scheduled against a plain JS Date or a Luxon DateTime for one-off execution instead of a recurring pattern, and every job can be pinned to a named IANA time zone or a fixed UTC offset via its Luxon-backed CronTime engine.

Beyond basic scheduling, the library handles the operational edge cases that come up in production: a waitForCompletion flag prevents overlapping runs when a tick callback is still executing, a configurable threshold decides whether a missed deadline (caused by a slow or busy process) should still fire or be skipped with a warning, and an errorHandler callback centralizes error handling instead of letting failures in onTick go unnoticed. Standalone helpers (sendAt, timeout, validateCronExpression) expose the same parsing engine without requiring a full CronJob instance.

What You Get

  • Six-field cron syntax (with a seconds slot) parsed and validated by a dedicated CronTime class
  • A CronJob class with both a classic positional constructor and a CronJob.from({...}) object-style factory
  • Time zone and UTC offset aware scheduling, backed by Luxon, with a runtime guard against setting both at once
  • Overlap and missed-deadline controls (waitForCompletion, threshold) for production-grade job scheduling
  • TypeScript types generated under strict compiler settings, plus standalone sendAt/timeout/validateCronExpression helpers

Common Use Cases

  • Scheduled data backups - ops teams run nightly backup or maintenance scripts on a cron expression tied to a specific time zone
  • Recurring notification digests - product teams fire periodic digest or reminder jobs (e.g. every Monday at 9am) using named day/month patterns
  • Delayed one-off tasks - developers schedule a single future task with a JS Date or Luxon DateTime instead of writing a recurring pattern
  • Guarding long-running jobs - teams with slow async tick callbacks use waitForCompletion to stop overlapping executions from piling up

Under The Hood

Architecture The package is organized around a clean split between time computation and job lifecycle: src/time.ts (CronTime) owns cron-expression parsing, field validation against constants.ts’s ranges/aliases, and next-fire-time computation via Luxon, while src/job.ts (CronJob) owns scheduling state, start/stop/fireOnTick lifecycle, callback registration, and self-rescheduling setTimeout chaining (including splitting waits longer than Node’s ~24.8-day setTimeout ceiling into repeated MAXDELAY chunks). Shared runtime validation, such as rejecting a CronJob/CronTime constructed with both timeZone and utcOffset, lives in src/errors.ts and is called from both classes to keep the invariant enforced in one place. src/index.ts re-exports the public surface (CronJob, CronTime, sendAt, timeout, validateCronExpression) and type contracts from src/types/, keeping the module boundary narrow and stable.

Tech Stack Written in TypeScript compiled to CommonJS/ES2015 via tsc -b, with a single runtime dependency on luxon (plus its @types/luxon) for time zone and DateTime handling — no other runtime dependencies. The devDependency set is oriented around automation: Jest with the @swc/jest transform and @fast-check/jest for property-based fuzz testing, ESLint (typescript-eslint) and Prettier enforced through Husky + lint-staged pre-commit hooks, and semantic-release wired to GitHub Actions for automated versioning, changelog generation, and npm publishing.

Code Quality Tests are split by concern (cron.test.ts, crontime.test.ts, errors.test.ts, threshold.test.ts) plus a dedicated cron.fuzz.ts using property-based fuzz testing against @fast-check/jest — a step beyond typical example-based unit tests for a scheduling library where edge cases in time math matter. tsconfig.json enables strict plus several stricter flags rarely turned on together (noUncheckedIndexedAccess, exactOptionalPropertyTypes, noImplicitOverride, noUnusedLocals), and CI runs a dedicated CodeQL workflow and an OpenSSF Scorecard workflow alongside the test suite, reflecting active attention to supply-chain and static-analysis signal, not just green tests.

API Design The primary CronJob constructor takes up to thirteen positional parameters, a holdover from the library’s long history, but the CronJob.from({...}) static factory offers a fully named, object-based alternative that most new usage in the README favors. Standalone sendAt/timeout/validateCronExpression functions let callers use the parsing engine without instantiating a class at all, and errors are surfaced through a dedicated CronError hierarchy rather than generic Error throws, giving consumers a stable type to catch against.

Used by 13 apps in this directory

TypeScript
96%
Other

Cal.diy

Scheduling

48,218

The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.

View details
95
Repo Health
86
Technical
65
Dependency
Built with
TypeScript96%
Updated yesterday
TypeScript
96%
Other

CapRover

Developer Tools · Devops · Hosting Control Panel

15,155

Deploy any app, database, or website to your own server in minutes—no Docker or Linux expertise required.

View details
88
Repo Health
82
Technical
68
Dependency
Built with
TypeScript96%
Updated yesterday
TypeScript
81%
Other

Directus

CMS · Low Code Platforms

37,783

Connect any SQL database and get instant REST and GraphQL APIs, a visual management Studio, and a native MCP server for AI agents — free for most organizations.

View details
92
Repo Health
82
Technical
76
Dependency
Built with
TypeScript81%
Vue18%
Updated 3 days ago
TypeScript
54%
MIT

FormBee

Forms Surveys

770

A self-hostable form backend that accepts HTML form submissions and routes them to email, Telegram, Discord, webhooks, and automation platforms — without writing any server-side code.

View details
29
Repo Health
48
Technical
70
Dependency
Built with
TypeScript54%
SCSS25%
HTML19%
Updated 1 years ago
TypeScript
96%
MIT

HyperDX

Developer Tools · Analytics · Monitoring

9,873

Open source observability platform that unifies logs, traces, metrics, and session replays on ClickHouse — now the core of ClickStack.

View details
88
Repo Health
83
Technical
68
Dependency
Built with
TypeScript96%
Updated yesterday
TypeScript
97%
Other

Infisical

Security · Devops

29,145

The open-source platform for secrets, certificates, privileged access, and AI agent security — all in one self-hostable system.

View details
91
Repo Health
84
Technical
65
Dependency
Built with
TypeScript97%
Updated yesterday
Python
51%
AGPL 3.0

Khoj

AI Assistants · Knowledge Management · Productivity

37,160

A self-hostable AI second brain that chats with your documents, searches the web, builds custom agents, and runs entirely on your own LLM.

View details
75
Repo Health
82
Technical
69
Dependency
Built with
Python51%
TypeScript36%
Updated 1 months ago
TypeScript
72%
Apache 2.0

Litlyx

Analytics

1,740

Cookie-free, AI-powered web analytics you can self-host in 30 seconds with Docker.

View details
45
Repo Health
51
Technical
72
Dependency
Built with
TypeScript72%
Vue26%
Updated 9 months ago
TypeScript
92%
Other

n8n

Automation · No Code Platforms

203,555

Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.

View details
95
Repo Health
87
Technical
66
Dependency
Built with
TypeScript92%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search