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:
To evaluate the runtime duration of a monitor, we start a timer when you ping your
/run endpoint and send an alert if
your defined threshold is reached before a
/complete ping is received. For example if you create a monitor with a 5 minute expected duration and your task pings
at 06:00, then dies due to a database connection failure, your alert will be triggered after 06:05. We usually send
alerts within 1 minute of failure.
A "ran less than" rule is also available on heartbeat monitors that can alert you if a task finishes too quickly. 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.