Node.js · node-cron

Monitor node-cron Scheduled Jobs

node-cron runs entirely in-process — if the Node process crashes, gets OOM-killed, or the server restarts without a process manager bringing it back, the schedule simply stops with no error logged anywhere. A ping at the end of the job closes that blind spot.

Setup

1

Create an incoming monitor

Add a heartbeat monitor in Pingtastic matching the cron schedule, with a grace period a bit past the expected run time.

2

Ping at the end of the scheduled callback

After the job logic completes successfully, call the Pingtastic ping URL.

jobs/nightlyCleanup.js
const cron = require('node-cron');

cron.schedule('0 3 * * *', async () => {
  // ...existing job logic...

  await fetch('https://ping.pingtastic.net/ping/nightly-cleanup');
});

Gotchas

  • ⚠node-cron has no persistence — if the process isn't running (crashed, deploy in progress, server restarted without a process manager), scheduled jobs just don't fire, with nothing logged. Run under a process manager (pm2, systemd) AND monitor the ping, since the two catch different failure modes.
  • ⚠A single unhandled rejection inside the scheduled callback can crash the whole Node process if nothing catches it — wrap the job body in try/catch so one bad run doesn't take down every future scheduled run too.

Questions

Does Pingtastic catch a crashed Node process running node-cron?

Yes indirectly — if the process is down, the scheduled job never runs and never pings, so Pingtastic alerts once the grace period lapses, even though the failure (a crashed process) isn't something node-cron itself can report.

Should I still use a process manager like pm2 alongside this?

Yes — a process manager restarts a crashed process so future runs still happen; Pingtastic alerts you about the gap in the meantime. The two are complementary, not alternatives.

Start monitoring your Node.js node-cron

Set up your first monitor in under five minutes.

Get started — $5/month