Docs › PM2 cron job monitoring with RunVouch

PM2 cron job monitoring with RunVouch

PM2 cron job monitoring for the daemon that was not there: PM2 can start a script on a cron expression (cron_restart) and let it exit (autorestart: false). The schedule is a property of the PM2 daemon; a reboot without pm2 startup and pm2 save, or a pm2 kill in a deploy script, and the job is gone.

How it runs on PM2 cron restart

Make rv the process PM2 starts (interpreter: none) with your script as the wrapped command, so every scheduled start becomes a run and the exit code becomes the status.

Store the key

env: { RUNVOUCH_KEY: ... } in the ecosystem file is stored in plain text; better: pm2 start ecosystem.config.js --update-env from a shell where the key is exported, or read it from a file with mode 600 in the script.

Wrap the job

// ecosystem.config.js
module.exports = { apps: [{
  name: "nightly-report",
  script: "rv",                 // the runvouch CLI; pip install runvouch
  interpreter: "none",
  args: "run nightly-report --evidence-file out/report.html --source pm2 -- node report.js",
  cron_restart: "0 2 * * *",
  autorestart: false,           // exit when done; PM2 starts it again at the next cron tick
  cwd: "/srv/report",
}]};

// same thing by hand, to test once:  rv run nightly-report --evidence-file out/report.html -- node report.js
// pm2 start ecosystem.config.js && pm2 save && pm2 startup
// rv agent nightly-report --cadence 24h --grace 30m --evidence

rv fails open: if RunVouch is unreachable the job still runs and you get one warning line.

Register the cadence and caps

rv agent nightly-report --cadence 24h --grace 30m --max-runtime 1h --evidence --cap-run-cost 2

Register the agent once, from anywhere with the key. Cadence is what turns a schedule that stopped into an alert; --evidence makes a run without evidence a failure; the caps pause the agent when it overspends.

What goes silent on PM2 cron restart

What PM2 cron restart does not tell you

PM2 records restarts, uptime and the last exit code per process in pm2 list and keeps stdout and stderr in ~/.pm2/logs. It has no notification of its own; PM2 Plus adds e-mail and Slack alerts for exceptions and restarts on a paid plan, and neither knows that a cron-restarted script was supposed to write a file tonight. A daemon that is not running reports nothing at all.

What RunVouch detects

AlertWhat it means here
MISSEDcadence plus grace passed and no run started
FAILEDnon-zero exit or a reported failure, with the stderr excerpt
NO_EVIDENCEthe run said ok but the file, URL or assertion you required is missing
STALLEDa run started and never ended within max runtime
RETRY_STORMthe same tool called with identical input many times in one run
BUDGET_RUN / BUDGET_DAYcost cap crossed; the agent is paused until you resume it
DRIFTduration or output size far off its 7-run baseline

Set up in two minutes

  1. Get a free key (3 agents, no card) and store it where this page says.
  2. wrap the job: copy the snippet above into the scheduled job.
  3. Register the cadence once: rv agent nightly-report --cadence 24h --grace 30m --evidence, or let the first run create the agent and set the cadence on the dashboard.
  4. Send one test alert: curl -X POST https://api.runvouch.com/v1/settings/test-alert -H "X-API-Key: $RUNVOUCH_KEY". The next missed, failed or empty run reaches the same channels.

Need a key? Get a free key · Stuck? contact