NestJS

Monitoring for NestJS scheduled tasks

NestJS makes scheduling clean with the @nestjs/schedule package and the @Cron() decorator — but those jobs run inside your app process. If the process crashes, a deploy restarts it, or the handler throws, the schedule stops with no error you would notice. A heartbeat tells you the moment a NestJS cron stops checking in.

How scheduling works in NestJS

The ScheduleModule registers cron, interval, and timeout jobs, and the @Cron() decorator runs a method on a schedule. It is ergonomic and testable — but it is still an in-process scheduler, so its reliability is tied to the lifetime of the Nest application.

Add a heartbeat to a @Cron() method

Do the work, then ping Cronmint on success. Keep the ping in its own try/catch so a network blip on the heartbeat never fails the job itself.

tasks.service.ts
import { Injectable, Logger } from '@nestjs/common';
import { Cron, CronExpression } from '@nestjs/schedule';

@Injectable()
export class TasksService {
  private readonly logger = new Logger(TasksService.name);

  @Cron(CronExpression.EVERY_HOUR)
  async handleHourly() {
    try {
      await this.runHourlyJob();
      await fetch('https://cronmint.com/ping/YOUR-TOKEN'); // check in on success
    } catch (err) {
      this.logger.error('hourly job failed', err);
      // no ping -> Cronmint alerts you about the missed run
    }
  }
}

Catch crashes and skipped runs

Set the Cronmint heartbeat interval to match your @Cron() schedule. If the Nest process is down when the job is due — an OOM kill, a failed deploy, a crash loop — no ping arrives and Cronmint alerts you, even though nothing was ever logged.

Monitor your NestJS cron jobs

5 jobs free, no card. Set up your first monitor in about 30 seconds.

Start free

Frequently asked questions

How do I monitor NestJS scheduled tasks?

Ping a heartbeat URL from inside your @Cron() handler after the work succeeds, and create a matching heartbeat monitor. If the process dies or the job throws, the ping stops and you get alerted.

What if my NestJS app restarts during a deploy?

If the app is not running when a job is due, that run is skipped silently. A heartbeat catches it because the expected check-in never arrives.

Do I need extra packages?

No. You already have @nestjs/schedule; Cronmint just needs an HTTP request, so a plain fetch/axios call in the handler is enough.