Skip to content

Instantly share code, notes, and snippets.

@Marigno
Last active January 29, 2021 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marigno/98160d16376e1a271113ac271aca10ce to your computer and use it in GitHub Desktop.
Save Marigno/98160d16376e1a271113ac271aca10ce to your computer and use it in GitHub Desktop.
Manual Scheduling

Scheduling Exports Using Cron Jobs

Whenever the cron job is run, WP All Export will export your data again, according to your settings. To set up a recurring export using manual cron jobs, just navigate to the Manage Exports page, then click on Scheduling Options:

You'll have to click on the "Manual Scheduling" option here:

Each export has two cron URLs - a trigger URL, and a processing URL – used to configure your cron job. You'll also find the File URL and the Bundle URL in here, which are used to retrieve the latest export files:

The trigger URL is structured like this:

http://YOUR-WEBSITE.com/wp-load.php?export_key=[YOUR_SECRET_KEY]&export_id=[YOUR_EXPORT_ID]&action=trigger

The processing URL is structured like this:

http://YOUR-WEBSITE.com/wp-load.php?export_key=[YOUR_SECRET_KEY]&export_id=[YOUR_EXPORT_ID]&action=processing

You can find your secret key on the All Export -> Settings screen, and the export ID on the Manage Exports screen.

If you want to run your export every 24 hours, you should run the trigger URL every 24 hours. If you want to run your export 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 export 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 a small percentage of your export 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 export is finished, or if there’s still work to be done. If there’s work to be done, it will export 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 export – and if so, it will do it. If not, it will “untrigger” the export. And now the processing script will have no effect, until the export is triggered again by the next run of the trigger script.

Examples to Set Up Export Cron Jobs

You should be able to create your cron job in your web hosting control panel. To create a cron job that hits the cron URLs, commonly the wget command is used. Here are some examples for wget:

wget -q -O /dev/null "https://example.com/wp-load.php?export_key=ph2Pyi_dMN&export_id=1&action=trigger"
wget -q -O /dev/null "https://example.com/wp-load.php?export_key=ph2Pyi_dMN&export_id=1&action=processing"

And here are some for curl:

curl -s "https://example.com/wp-load.php?export_key=ph2Pyi_dMN&export_id=1&action=trigger" > /dev/null
curl -s "https://example.com/wp-load.php?export_key=ph2Pyi_dMN&export_id=1&action=processing" > /dev/null

Please note that in both cases, the URLs need to be in quotes. Here's an example in cPanel:

To ask your web hosting provider to set up the cron for you, use this e-mail template:

Hi Support,

Please set up two cron jobs.

CRON JOB 1 Fetch this URL every 24 hours: http://YOUR-WEBSITE.com/wp-load.php?export_key=[YOUR_SECRET_KEY]&export_id=[YOUR_EXPORT_ID]&action=trigger

CRON JOB 2 Fetch this URL every 2 minutes: http://YOUR-WEBSITE.com/wp-load.php?export_key=[YOUR_SECRET_KEY]&export_id=[YOUR_EXPORT_ID]&action=processing

Thanks, Your Name

If your web host doesn’t have a cron feature, you can use an external service like EasyCron.

Call Cron URLs from the Command Line

You can call the WP All Export cron URLs from the command line. This may be necessary if your site's configuration won't allow inbound calls to the regular cron URLs.

It'd look something like this:

php-cgi /path/to/yourwordpressinstall/wp-load.php export_key=ABC123 export_id=5 action=trigger
php-cgi /path/to/yourwordpressinstall/wp-load.php export_key=ABC123 export_id=5 action=processing

You may have to include a path to php, e.g.:

/usr/local/php71/bin/php-cgi /home/yourusername/public_html/wp-load.php export_key=A1B23C export_id=3 action=trigger
/usr/local/php71/bin/php-cgi /home/yourusername/public_html/wp-load.php export_key=A1B23C export_id=3 action=processing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment