Scrums.com logomark
SovTech is now Scrums.com! Same company, new name.
SovTech is now Scrums.com!!
Read more here

Cron Job Monitoring API

API
By:
API Layer
Updated:
April 4, 2025

About this Cloud Hub Solution:

Monitoring cron jobs can be a challenging task, despite its importance. The main reason for this is that these tasks typically run on servers that are inaccessible from outside HTTP calls, making it difficult to retrieve information from them. The only way to get logs from these servers is for the cron jobs to send the logs themselves to another service.

This is where the Cron Job Monitoring API comes in. Every time your services run, they send a ping event to this API, reporting either that they are running smoothly or that there is a problem. If your service fails to send a ping within the designated grace time, the Cron Job Monitoring API will immediately send a notification to you via email. It's a simple yet effective way to stay on top of your cron job monitoring!

How to Step by Step

1. Create a new "check"We start using the API by creating a new check.

Don't forget to give your check a beautiful and memorable name. To create a new check, simply use the POST /check endpoint, which will provide you with a unique "ping URL" in response.

The next step is for your application to start pinging this ping URL. This will enable the Cron Job Monitoring API to track the status of your application and notify you if any issues arise.

curl --location \--request POST 'https://api.apilayer.com/cron_monitoring/check' \--header 'apikey: API KEY' \--data-raw 'My First Check'When a new check is created all of it information is returned with the response{    "id": "5dfaf9d0-3a2c-40dd-902e-cc0fb352b86b",    "name": "My First Check",    "status": "unknown",    "ping_url": "https://api.apilayer.com/cron_monitoring/p/5dfaf9d0-3a2c-40dd-902e-cc0fb352b86b",    "schedule": {        "type": "cron",        "cron_expression": "0 * * * *",        "grace_time": 60,        "timezone": "UTC",        "last_check_at": null,        "cron_description": "Every hour"    },    "integrations": [        {            "type": "email",            "email": "[email protected]",            "owner": "[email protected]"        }    ]}

2. Pinging the API regularlyPlace the following piece of code in your cron jobs that pinging for this check wherever you see fit.

You have complete control over how often you ping the API - you can do it as frequently as you want, or even just once within a loop. The choice is entirely yours.

The Cron Job Monitoring API will store the last 1000 ping requests for you, allowing you to review and analyze the activity of your application. You can retrieve the entire list of pings using the GET /check/{id}/pings endpoint.

curl --location \--request POST 'https://api.apilayer.com/cron_monitoring/ping/5dfaf9d0-3a2c-40dd-902e-cc0fb352b86b' \--header 'apikey: API KEY' \--data-raw 'This is some description'

3. To notify the API that your application is experiencing issues, simply append /fail to the end of your ping URL and send the request.

In addition to reporting failures, you can also send /start and /finish status codes to provide more detailed information about the status of your application.

When you send a message with the /fail status, the API will intelligently shorten the grace time, allowing you to receive alerts more quickly if the cron job is delayed. This ensures that you stay on top of any issues that may arise with your application.

curl --location \--request POST 'https://api.apilayer.com/cron_monitoring/ping/5dfaf9d0-3a2c-40dd-902e-cc0fb352b86b/fail' \--header 'apikey: API KEY' \--data-raw 'This is the ping description.'

4. You can retrieve information about your check, including its description and schedule, using the GET /check/ endpoint.

The API will use the cron expression you provide to determine when to expect pings from your service. If no ping is received within the specified time frame, the API will wait for the duration of the grace time before sending an alert.

This ensures that you are notified promptly if your service experiences any issues or delays, allowing you to take swift action to resolve the problem.

curl --location \--request GET 'https://api.apilayer.com/cron_monitoring/check/5dfaf9d0-3a2c-40dd-902e-cc0fb352b86b' \--header 'apikey: API KEY'

5. To retrieve a comprehensive list of all pings for a check, you can use the GET /pings endpoint.

This will provide you with a single view of all ping activity, allowing you to review and analyze the history of pings for your check.

curl --location \--request GET 'https://api.apilayer.com/cron_monitoring/check/5dfaf9d0-3a2c-40dd-902e-cc0fb352b86b/pings' \--header 'apikey: API KEY'

6. By default, the API sets the crontab expression to 0 * * * *, which schedules pings to occur once a day. However, you can customize this schedule to fit your needs by using the PUT /schedule/cron endpoint.

This allows you to update the crontab expression to a schedule that suits your specific requirements, giving you more control over when pings are sent and when alerts are triggered.

curl --location \--request PUT 'https://api.apilayer.com/cron_monitoring/check/5dfaf9d0-3a2c-40dd-902e-cc0fb352b86b/schedule/cron' \--header 'apikey: API KEY' \--data-raw '0 */3 * * *'

7. By default, the API sets the grace time to 60 minutes. However, you can adjust this value to suit your needs by using the PUT /schedule/grace endpoint.

This allows you to update the grace time to a duration that fits your specific requirements, giving you more control over when alerts are triggered if pings are delayed.

curl --location \--request PUT 'https://api.apilayer.com/cron_monitoring/check/5dfaf9d0-3a2c-40dd-902e-cc0fb352b86b/schedule/grace' \--header 'apikey: API KEY' \--data-raw '90'8. Changing the timezone/The API will take UTC as the default timezone. 

8. You can update the timezone for your schedule by using the PUT /schedule/timezone endpoint.

This allows you to adjust the timezone to match your specific location or requirements, ensuring that pings and alerts are triggered at the correct times.

curl --location \--request PUT 'https://api.apilayer.com/cron_monitoring/check/5dfaf9d0-3a2c-40dd-902e-cc0fb352b86b/schedule/timezone' \--header 'apikey: API KEY' \--data-raw 'UTC+04:00'

Explore Tech Stacks Related to

Cron Job Monitoring API

Looking To Build Software Of Your Own?

Custom Software Development

Custom app solutions.
Explore software development
arrow

Mobile App Development

Custom mobile development.
Explore mobile app development
arrow

Product Design

User interface/User experience design
Explore product design
arrow

Web App Development

Custom web development
Explore web app development
arrow