Home > Docs > Refresh WooCommerce Product Feed Using Server Cron

Refresh WooCommerce Product Feed Using Server Cron

Last updated on October 3, 2024

A cron job is a scheduled task that runs regularly on your server. The WooCommerce Product Feed Plugin helps you to automate your product feed updates scheduled cron job.

The two types of schedulers we use here are:

  1. WordPress Cron
  2. Server Cron

Advantage of Server Cron over WordPress Cron

WordPress cron is highly dependent on-site activity. If the site remains idle for some time the auto-update may never occur.

But server cron doesn’t have this dependency.

When the volume of data to be processed necessitates triggering the URL every minute, use server cron scheduling. This option is most preferred:

  • It is also a better option for users with a website on managed hosting.
  • To generate a unique URL that can be added to your system to trigger the events. 

Step1: Scheduling a server cron

While creating a feed, you can configure the scheduling details of cron as a first step.

  • In Step 1: Create a new feed, and move to the Automation section. There you will find the following features:
    • Auto-refresh interval – The interval in which the feed must be auto-refreshed. The feed can be refreshed Daily, Weekly, Monthly Every 12 hours, Every 6 hours, and Every 30 minutes. You can also disable auto-refresh by specifying No refresh.
    • Time – The time at which the automatic feed-refresh must take place.
    • Cron Type – The type of cron to be used, Select Server cron.

Step 2: Generate the trigger URL

The Trigger URL that can be used in different servers to run a cron job is generated after the feed is created successfully.

  • From the Dashboard, Click on WebToffee Product Feed > Scheduled Feeds.
  • Under the Actions column, click on the Cron URL hyperlink.
  • In the subsequent window that pops up, copy the cron URL and click on the OK button.Cron URL

Running server cron on different servers

Here, we have listed some servers and how to run server crons on them. 

cPanel

  1. In cPanel, under the Advanced section of the Main Page menu, select Cron Jobs.
  2. A new table will appear for setting time intervals and adding new scripts.
  3. For simpler configuration, the drop-down menu has common settings such as: Once Per Week or Once Per Day, etc. We suggest you select the time interval as Every minute.
    To customize the settings differently from that of the drop-down menu, enter a time interval on the left side boxes or use the menus on the right to select from typical entries for each period.
  4. Finally, enter the command or the path to your script in the Command field.Running server cron on cPanel
  5. Hit the “Add New Cron Job” button to save. The cron will run the script automatically at the selected intervals.

Example: The below-mentioned command is a combination of the trigger URL (fetched from the plugin: WooCommerce Product Feed Plugin) and command. This is the command format followed in cPanel. To dump unwanted log files, simply add /dev/null.

Command:

Cloudways

  1. Log in to the Cloudways platform.
  2. From the top menu bar, click on Applications.
  3. From the appearing list, select the application you want to set the cron for.
  4. Under Application Management, click on Cron Job Management section.
  5. Click on the ADD NEW CRON JOB button.
  6. Now, decide how often the cron job should run. You can either set it on your own or select the pre-defined values from the Common settings dropdown. However, we recommend you to select the time interval as Every minute.
  7. As the next step, set the type of script you want to run (PHP, curl, or wget) and the command to execute.
  8. Click on submit to save.
  9. The cron job will be listed in the BASIC tab once done.
  1. if you prefer to use command-line switches or other advanced cron settings, switch to the advanced editor under the Advanced tab.
Cron Job Management in Cloudways

Example: Below mentioned is the command format in which cron runs in Cloudways. The command is a combination of the trigger URL (fetched from the plugin: WooCommerce Product Feed Plugin) and the command.

If you do not want to get emails when the script runs, add /dev/null 2>&1 at the end of the command.

EasyCron

EasyCron is a paid online service that allows users to specify the execution time of cron jobs in 3 ways:

  • Manually
  • By interval
  • By cron expression
  1. From your cron job dashboard, click on the +Cron Job button.
  2. Enter the trigger URL in the field URL to call.
  3. Under When to execute, select Every minute.Creating a cron job in easy cron
  4. Finally, click on the Create Cron Job button, and you are done!

Thus, you can run server cron jobs on different servers using the trigger URL generated using the WooCommerce Product Feed Plugin.