External Cron

Configure external system cron for more reliable background processing

Overview

External Cron uses your server's system cron (cPanel, CLI, or other cron service) to trigger PrimeLink's background processing. This provides more reliable and timely execution compared to WordPress Cron, which depends on site traffic.

External Cron is ideal for sites with low traffic, when you need precise timing, or when WordPress Cron isn't reliable enough for your needs.

Why Use External Cron?

Advantages

  • More Reliable: Runs on schedule regardless of site traffic
  • Faster Execution: No waiting for page visits
  • Precise Timing: Runs exactly when scheduled
  • Better for Low-Traffic Sites: Doesn't depend on visitors
  • More Control: You control when it runs

When to Use

Consider External Cron if:

  • Your site has low traffic
  • You need precise scheduling
  • WordPress Cron is unreliable on your server
  • You have server access to configure cron
  • You need faster background processing

Setting Up External Cron

Step 1: Enable External Cron Mode

  1. Go to PrimeLink → Settings
  2. Navigate to Automation tab
  3. Find "Cron Mode" section
  4. Select "External Cron (cPanel/CLI)" from dropdown
  5. Save settings

Step 2: Get Your Cron Token

PrimeLink will generate a cron token automatically:

  • Token is displayed in the settings
  • Copy this token - you'll need it for the cron URL
  • Keep it secret - it authorizes cron requests
  • You can regenerate it if needed

Step 3: Get Your Cron URL

PrimeLink provides a cron URL to call:

  • URL is displayed in settings
  • Format: https://yoursite.com/wp-json/primelink/v1/import/cron-tick?token=YOUR_TOKEN
  • Copy this URL for your cron job

Configuring Server Cron

cPanel Cron Jobs

If you use cPanel:

  1. Log into cPanel
  2. Go to Advanced → Cron Jobs
  3. Add a new cron job
  4. Set schedule (e.g., every minute: * * * * *)
  5. Command: curl -s "YOUR_CRON_URL" > /dev/null 2>&1
  6. Or use: wget -q -O - "YOUR_CRON_URL" > /dev/null 2>&1
  7. Save the cron job

Command Line (SSH)

If you have SSH access:

  1. SSH into your server
  2. Edit crontab: crontab -e
  3. Add line: * * * * * curl -s "YOUR_CRON_URL" > /dev/null 2>&1
  4. Save and exit

Cron Schedule

Recommended schedule:

  • Every Minute: * * * * * (most responsive)
  • Every 2 Minutes: */2 * * * * (good balance)
  • Every 5 Minutes: */5 * * * * (less frequent)
💡 Tip: For most use cases, running every minute is recommended. This ensures background jobs process quickly without overloading your server.

Cron URL Format

Full URL Structure

The cron URL follows this format:

https://yoursite.com/wp-json/primelink/v1/import/cron-tick?token=YOUR_TOKEN

Components

  • Base URL: Your WordPress site URL
  • Endpoint: /wp-json/primelink/v1/import/cron-tick
  • Token Parameter: ?token=YOUR_TOKEN

Example

https://example.com/wp-json/primelink/v1/import/cron-tick?token=abc123xyz789

Testing External Cron

Manual Test

Test your cron URL manually:

  1. Copy your cron URL
  2. Open it in a browser or use curl
  3. You should see: {"message":"Cron ticked all running imports."}
  4. Check your imports/exports to verify they're processing

Using cURL

Test from command line:

curl "YOUR_CRON_URL"

Using wget

Test with wget:

wget -q -O - "YOUR_CRON_URL"

Verify It's Working

After setting up cron:

  • Start an import or export with iterative processing
  • Wait for the cron to run (based on your schedule)
  • Check import/export progress
  • Verify it's processing in iterations

Security Considerations

Cron Token

  • Keep Secret: Don't share your cron token
  • Regenerate if Compromised: Generate new token if exposed
  • Use HTTPS: Always use HTTPS for cron URL
  • Restrict Access: Only allow cron from your server IP if possible

Best Practices

  • Use strong, randomly generated tokens
  • Don't commit tokens to version control
  • Monitor cron access logs
  • Regenerate tokens periodically
⚠️ Security Warning: Your cron token authorizes background processing. Keep it secret and only use it in your server cron configuration. Never expose it publicly or in client-side code.

Troubleshooting

Cron Not Running

  • Check Cron Job: Verify cron job is set up correctly
  • Test URL Manually: Test the cron URL in browser/curl
  • Check Token: Verify token matches settings
  • Check Logs: Review server cron logs
  • Verify Mode: Ensure External Cron mode is enabled

403 Forbidden Error

  • Invalid Token: Token doesn't match - regenerate and update cron
  • Wrong URL: Verify cron URL is correct
  • Token Missing: Ensure token parameter is included

Jobs Not Processing

  • Check Mode: Verify External Cron mode is enabled
  • Test Cron: Manually trigger cron URL
  • Check Jobs: Verify imports/exports are set to use iterative processing
  • Review Logs: Check import/export logs for errors

Switching Back to WordPress Cron

How to Switch

To switch back to WordPress Cron:

  1. Go to PrimeLink → Settings
  2. Navigate to Automation tab
  3. Select "WordPress Cron (default)" from dropdown
  4. Save settings
  5. Remove or disable your server cron job

No Data Loss

Switching between modes:

  • Doesn't affect existing imports/exports
  • Running jobs continue with new mode
  • No data is lost
  • Can switch anytime

Best Practices

  • Test First: Test cron URL manually before setting up server cron
  • Use HTTPS: Always use HTTPS for cron URL
  • Keep Token Secret: Never expose cron token publicly
  • Monitor Logs: Regularly check cron execution logs
  • Set Appropriate Schedule: Don't run too frequently (every minute is usually enough)
  • Backup Configuration: Document your cron setup
  • Verify Regularly: Periodically verify cron is working

Next Steps

⏰ WordPress Cron

Learn about WordPress Cron as an alternative

Learn More →
⚡ Performance & Optimization

Optimize import and export performance

Learn More →
📅 Scheduling

Learn about scheduling imports and exports

Learn More →