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 --evidencerv 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
- Without
pm2 saveand a workingpm2 startuphook, a reboot brings back nothing; MISSED fires that night. - With
autorestart: true(the default) a script that exits is restarted immediately in a loop, at up to 15 restarts before PM2 gives up (max_restarts); every restart is a new run in RunVouch, so the pattern is obvious on the dashboard. cron_restartrestarts a process that is still running at the tick; a slow run is cut short with no exit code of its own, which RunVouch reports as STALLED.- PM2 logs (
~/.pm2/logs) grow until pm2-logrotate is installed;--logonrv runkeeps the part that matters as evidence.
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
| Alert | What it means here |
|---|---|
| MISSED | cadence plus grace passed and no run started |
| FAILED | non-zero exit or a reported failure, with the stderr excerpt |
| NO_EVIDENCE | the run said ok but the file, URL or assertion you required is missing |
| STALLED | a run started and never ended within max runtime |
| RETRY_STORM | the same tool called with identical input many times in one run |
| BUDGET_RUN / BUDGET_DAY | cost cap crossed; the agent is paused until you resume it |
| DRIFT | duration or output size far off its 7-run baseline |
Set up in two minutes
- Get a free key (3 agents, no card) and store it where this page says.
- wrap the job: copy the snippet above into the scheduled job.
- 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. - 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