Cron Job Monitoring with the Linux crontab

Cron monitoring in crontab #

Oh Dear users can add cron job monitoring to any existing crontab on your Linux servers. When you create a cronjob monitor in your Oh Dear account, you're given a unique pingback URL that should be called every time a cronjob completes.

In this guide, we'll cover how you can implement that in your existing crontab.

Example crontab monitoring #

Imagine you have the following cronjob configured on your Linux server.

$ crontab -l
55 * * * *

You can modify this line so it calls back to our Ping URL whenever your script has executed successfuly.

$ crontab -l
55 * * * * && curl -fsS --retry 3 -o /dev/null

By using the && operation in Bash, we will only call our URL if your script finished with an exit code of 0. In other words: we'll only call our URL if your script executed without any error.

Note: make sure your script throws a non-zero exit code whenever it has encountered a failure condition.

Example script monitoring in Bash #

Alternatively, if you are calling a Bash script in your crontab, you can move the curl call to the very last line of your Bash script instead. If curl is not available on your system, you may also use wget.

curl --retry 3
wget -O /dev/null

This allows you to implement cron job monitoring to any Bash script, regardless of how it's being called.

Advanced use of cron job reporting #

Next to providing us a ping whenever your script has finished, you can also actively send failure states to us.

For more information about sending failures or debug-information like memory consumption & runtime duration, please see the advanced options of our cron job monitoring.

Was this page helpful to you? Feel free to reach out via or on Twitter via @OhDearApp if you have any other questions. We'd love to help!