Skip to content

Cron Jobs

Cron jobs are an efficient way to automate the execution of API requests at specific intervals.

This guide will walk you through the process of creating cron jobs for the Publisher Indexing API.

Creating Cron Job Expressions

To create a cron job that runs once per minute you can use the * * * * * cron expression.

Each asterisk corresponds to a time unit (minute, hour, day of the month, month, and day of the week), and the asterisk means any value for that unit.

To create cron expressions you can use either of the following two apps:

Creating Cron Jobs

Using Shell

  1. Open the Crontab

Open your server’s crontab using the following command:

crontab -e
  1. Add a New Entry

Add a new entry to schedule the execution of the API request. For example, to call the /api/rss endpoint every 1 minute, add the following line:

* * * * * curl -H "api-key: your_api_key_here" ""

Replace your_api_key_here and your_feed_url with your actual API key and feed URL, respectively.

  1. Save and Exit

Save the crontab file and exit the editor. Your cron job will now be scheduled to run at the specified interval.

Setting up multiple cron jobs

To set up multiple cron jobs using shell, simply add additional lines to your crontab file, one for each cron job, following the same format as before:

* * * * * curl -H "api-key: your_api_key_here" ""
* * * * * curl -H "api-key: your_api_key_here" ""

Replace your_api_key_here, your_first_feed_url, and your_second_feed_url with your actual API key and feed URLs, respectively.

Managing Existing Cron Jobs

To manage existing cron jobs via shell, open the crontab file using the command:

crontab -e

Edit the existing lines to modify the cron jobs or remove the lines corresponding to the cron jobs you want to delete. Save and exit the editor to apply the changes.

Using cPanel

If your web hosting provider uses cPanel, you can set up cron jobs using the built-in Cron Job manager. Here’s a step-by-step guide:

  1. Log in to your cPanel account.

  2. Scroll down to the “Advanced” section and click on “Cron Jobs.”

  3. Under “Add New Cron Job,” choose the desired frequency for your cron job from the “Common Settings” dropdown menu or set custom values for minute, hour, day, month, and weekday.

  4. In the “Command” field, enter the following:

curl -H "api-key: your_api_key_here" ""

Replace your_api_key_here and your_feed_url with your actual API key and feed URL, respectively.

  1. Click “Add New Cron Job” to save and schedule the cron job.

Setting Up Multiple Cron Jobs in cPanel

In cPanel’s “Cron Jobs” manager, simply repeat the process of adding a new cron job for each additional job you want to set up.

Make sure to adjust the “Command” field to include the appropriate feed URL for each new job.

Using Cron Job Services

There are various online services that provide cron jobs as a service. Such as:

  • EasyCron
  • Cronitor
  • SetCronJob

To set up a cron job using one of these services, follow the instructions provided by the chosen service.

Once you have registered for an account you should be able to add a Cron job using the instructions above. For example:

curl -H "api-key: your_api_key_here" ""