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:
- WordPress Cron
- 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.
Running server cron on different servers
Here, we have listed some servers and how to run server crons on them.
cPanel
- In cPanel, under the Advanced section of the Main Page menu, select Cron Jobs.
- A new table will appear for setting time intervals and adding new scripts.
- 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. - Finally, enter the command or the path to your script in the Command field.
- 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
- Log in to the Cloudways platform.
- From the top menu bar, click on Applications.
- From the appearing list, select the application you want to set the cron for.
- Under Application Management, click on Cron Job Management section.
- Click on the ADD NEW CRON JOB button.
- 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.
- As the next step, set the type of script you want to run (PHP, curl, or wget) and the command to execute.
- Click on submit to save.
- The cron job will be listed in the BASIC tab once done.
The Basic tab does not allow any switches for wget and curl. You will need to utilize the Advanced tab to apply switches.
- if you prefer to use command-line switches or other advanced cron settings, switch to the advanced editor under the Advanced tab.
Only account owners or team members with full privileges can edit cron jobs via the Advanced tab.
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
- From your cron job dashboard, click on the +Cron Job button.
- Enter the trigger URL in the field URL to call.
- Under When to execute, select Every minute.
- 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.