Scheduling An Import Using Cron Jobs
Each time the cron is run, WP All Import will download your XML or CSV file from the specified URL and update, delete, and create posts on your site according to your settings.
To set up a recurring import using cron jobs, specify the URL to your XML or CSV file on the Import Settings page.
Then visit the Cron Scheduling link on the Manage Imports page to get the cron URLs to run.
Each import has two cron URLs – a trigger URL, and a processing URL.
The trigger URL will look something like this:
The processing URL will look something like this:
You can find your secret key on the WP All Import -> Settings screen, and the import ID on the Manage Imports screen.
If you want to run your import every 24 hours, you should run the trigger URL every 24 hours. If you want to run your import once per week, you should run the trigger URL every week.
The processing URL should be run every two minutes because it may not finish your import in one run. The reason is that many hosts have maximum script execution times in place, so its only possible for the processing script to finish only a small percentage of your import before it is timed out.
If this is the case and the processing script is run again after two minutes, it checks to see if your import is finished, or if there’s still work to be done. If there’s work to be done, it will import posts for as long as it can, or two minutes, whichever is longer.
Then, on the next run of the processing script, it will see if more work needs to be done on the import – and if so, it will do it. If not, it will “untrigger” the import. And now the processing script will have no effect, until the import is triggered again by the next run of the trigger script.
Setting Up Cron Jobs
The instructions for setting up cron jobs vary across hosts. Commonly, you can do it in your web hosting control panel.
To create a cron job that hits the cron URLs, commonly the wget command is used. Examples are on the Manage Imports -> Cron Scheduling screen of WP All Import.
To ask your web hosting provider to set up the cron for you, use this e-mail template:
Please set up two cron jobs.
CRON JOB 1
Fetch this URL every 24 hours: http://YOUR-WEBSITE.com/wp-cron.php?import_key=[YOUR_SECRET_KEY]&import_id=[YOUR_IMPORT_ID]&action=trigger
CRON JOB 2
Fetch this URL every 2 minutes: http://YOUR-WEBSITE.com/wp-cron.php?import_key=[YOUR_SECRET_KEY]&import_id=[YOUR_IMPORT_ID]&action=processing
If your web host doesn’t have a cron feature, you can use an external service like SetCronJob.com.