Monitor node-cron scheduled tasks
On this page
A node-cron schedule exists only while its process runs. If the process crashes, is redeployed, or is replaced by a second copy, ticks are lost or doubled, and the task code never gets the chance to say so. Ping from the task and the silence becomes an alert.
How can a scheduled job fail silently on node-cron?
- The schedule lives in memory. A restart between two ticks loses the tick, and node-cron does not replay it.
- node-cron's day-of-month and day-of-week fields are combined with AND, so a line that Linux cron reads as "either" runs on fewer days in node-cron. The README says node-cron is not Quartz compatible either: Quartz numbers Sunday as 1, node-cron as 0 or 7.
- Without noOverlap, a task still running when the next tick arrives runs twice at once. With noOverlap, the late tick is skipped, which is a missed run nobody sees unless it is monitored.
- With several instances of an app each instance schedules the task, unless you enable the distributed option with a coordinator.
- The library emits events such as execution:missed, execution:overlap and execution:failed, but nothing listens to them unless you wire them up.
What are the limits of node-cron?
| Limit | What the documentation says |
|---|---|
| Precision | Cron expressions with second-level precision are supported. |
| Day fields | Day-of-month and day-of-week are combined with AND, not OR. |
| Time zone | The timezone option takes an IANA name such as America/Sao_Paulo. |
| noOverlap | Skips a tick when the previous run is still active. |
| distributed | Makes only one instance run each tick; a Redis coordinator is available for high availability. |
How do you add a CronMissed ping to node-cron?
Wrap the task body once in a helper, so every scheduled task reports the same way. The helper pings the start, runs the task, and pings success or failure. Node 18 and later have fetch and AbortSignal.timeout built in.
import cron from 'node-cron';
const ping = (url, suffix = '', body) =>
fetch(url + suffix, { method: body ? 'POST' : 'GET', body, signal: AbortSignal.timeout(10_000) }).catch(() => undefined);
function monitored(url, task) {
return async () => {
await ping(url, '/start');
try {
await task();
await ping(url);
} catch (error) {
await ping(url, '/fail', String(error?.stack ?? error).slice(-100_000));
throw error;
}
};
}
cron.schedule('15 3 * * *', monitored('https://ping.cronmissed.com/5f0c1b2e-7a3d-4c8e-9b61-2d4f8a7e3c10', nightlyCleanup), { timezone: 'UTC', noOverlap: true });Which check settings fit node-cron?
Create a cron check with the same expression and time zone. Because the library fires on the second, grace can be short, one or two minutes plus the run time. Remember the AND rule when you copy an expression from a Linux crontab: if both day fields are set the check should expect fewer runs than cron would give.
How do you confirm the check works?
- Temporarily schedule the task every minute, let it run once, and confirm the pings.
- Kill the process and confirm the check goes late, then down.
- Start two copies and confirm with the ping log that you see two pings per tick, which is the cue to turn on distributed.
Sources
- node-cron README , read 22 October 2026
Questions and answers
- No. The schedule is in memory, so a tick that falls while the process is down is gone. The heartbeat is how you find out that a tick was lost.
- It can, and it keeps the task untouched. Using the event for failure and the start of a run is also reasonable. Keep the wrapper if you want one place that reports all three.
Does node-cron handle a missed tick after a restart?
Can the ping go in the execution:finished event instead?
Create a check, add the ping to the job, and CronMissed alerts you the first time a run is late or reports a failure.
Start monitoring