Cronitor will alert you if your job runs longer than expected. These alerts provide value beyond simple pass/fail alerts, for example:
To send duration alerts, Cronitor must know when your job starts running and when it completes successfully. To
report these events, you should ping your
/run endpoint as your job starts and your
endpoint when it completes. If you are using CronitorCLI
exec this is done for you automatically. For more details on ping URL endpoints and where you should integrate your ping requests,
/complete pings, Cronitor is able to calculate an expected duration range for your job.
The predictions grow more accurate as we learn more about your job performance but will not work perfectly for every job. If it's normal for job runtime to vary significantly,
or if you are receiving has not completed alerts earlier than you would like, you can provide a fixed runtime duration:
When using Cron Job monitoring, or if you define a "ran longer than" heartbeat rule, we start the timer when you ping your
/run URL and send the alert once
your defined threshold is reached. For example if you define a rule with a 5 minute duration and your job pings
at 06:00, then dies due to a syntax error in your code, your alert will be triggered after 06:05. We usually send
alerts within 1 minute of failure.
A "ran less than" heartbeat rule is available. This rule is not evaluated until we receive a
/run ping and subsequent
/complete ping. In most cases
your rule is evaluated within 1 minute of your
/runendpoint before your job and your
/completeendpoint after. A missing or misplaced
/completeping is the most common integration mistake.
If you've verified that you're pinging
/complete appropriately, try changing the logic in your
&& "and" logic to
; "or" logic.
Switch from only pinging
/complete if your command finishes successfully:
* */2 * * * curl -m 10 https://cronitor.link/d3x0/run ; /path/to/db_backup.sh && curl -m 10 https://cronitor.link/d3x0/complete
To always pinging
* */2 * * * curl -m 10 https://cronitor.link/d3x0/run ; /path/to/db_backup.sh ; curl -m 10 https://cronitor.link/d3x0/complete
By changing to
; you will ping your Cronitor URL even if your command exits with a non-0
exit code. If this works, you should investigate why your command is exiting with an error code.