NextGen Smart Data Importer supports two distinct cron execution models:
- Background Cron (Global / Polling): Processes queued media downloads, daily retention cleanup, and all due/queued imports using a global master token or WP-Cron.
- Event-Specific / Import-Specific Cron: Targets a single import job using its own schedule (
nextgen_run_scheduled_import_hook), its own per-importcron_secret_key, or direct sync/run REST triggers.
1. Background Cron (Global Queue & Maintenance)
What It Handles
- Queued Media Downloads (
NextGen_Image_Processor::process_queue()):- Processes up to 50
pendingrows per run fromwp_nextgen_image_queue(protected bynextgen_image_queue_lockand a30sdownload timeout). - Runs automatically on WP-Cron hook
nextgen_image_processor_cronand at the start of every/cron/processexternal cron call.
- Processes up to 50
- Global Scheduled & Queued Imports (
get_next_import_to_process($token, true)):- When triggered with the Global External Cron Secret Key, processes due scheduled imports and queued imports that do not override the global token, including remote sync (
ftp,sftp,s3,google_sheets).
- When triggered with the Global External Cron Secret Key, processes due scheduled imports and queued imports that do not override the global token, including remote sync (
- Daily Retention Cleanup (
nextgen_importer_daily_maintenance):- WP-Cron daily hook registered by
NextGen_Retention_Workerfor log/data retention maintenance.
- WP-Cron daily hook registered by
How to Configure Background Cron
Step 1: Set Up the Global External Cron Key (Pro)
- Go to NextGen Importer → Global Settings → External Cron.
- Copy or generate your Cron Secret Key (
cron.secret_key). - Configure your preferred Time Limit (
cron.time_limit, default120s) and optional Sleep (cron.sleep). - Click Save Settings.
Step 2: Add the Cron Job on Your Server
Use the rest_route URL format with &token= and double quotes "...":
- SSH /
crontab -e(full line, runs every minute):
cron
* * * * * /usr/bin/curl -s "https://yoursite.com/index.php?rest_route=/nextgen-importer/v1/cron/process&token=YOUR_GLOBAL_SECRET_KEY" > /dev/null 2>&1(Run which curl over SSH if your server installs curl at a custom path.)
- cPanel / DirectAdmin / Hostinger Cron UI (command only):
- Select Once Per Minute (
* * * * *) in the panel's schedule dropdowns. - Paste only the command:
- Select Once Per Minute (
bash
curl -s "https://yoursite.com/index.php?rest_route=/nextgen-importer/v1/cron/process&token=YOUR_GLOBAL_SECRET_KEY" > /dev/null 2>&1- External URL Monitors (EasyCron, UptimeRobot, Plesk "Fetch a URL"):
text
https://yoursite.com/index.php?rest_route=/nextgen-importer/v1/cron/process&token=YOUR_GLOBAL_SECRET_KEY2. Event-Specific / Import-Specific Cron
What It Handles
Use event-specific cron when a particular import needs its own isolated schedule, remote sync cadence, or dedicated security token—without triggering other imports.
- Per-Import External Cron Token (
cron_secret_key):- Each import can define its own
cron_secret_keyin Import Settings (Step 3). verify_cron_token()andvalidate_import_token()inNextGen_Pro_Schedulerscope/cron/process&token=IMPORT_SECRET_KEYspecifically to that import.
- Each import can define its own
- Per-Import WP-Cron Schedule (
nextgen_run_scheduled_import_hook):- Scheduled per import via the Schedule action (
/nextgen-importer/v1/schedule) or auto-resume (/nextgen-importer/v1/schedule-resume/{import_id}). - On completion, fires
nextgen_pro_finalize_scheduled_import.
- Scheduled per import via the Schedule action (
- Direct On-Demand Event Triggers (REST API):
/nextgen-importer/v1/sync-run-import/{import_id}and/nextgen-importer/v1/sync-and-run/{import_id}trigger a specific import immediately (useful for webhooks, CI/CD, or external automation).
How to Configure Event-Specific Cron
Option A: Per-Import External Cron (Recommended for Reliable Isolated Jobs)
- Start or open an import and go to Step 3: Import Settings → Cron / Scheduling.
- Set a unique Import Cron Secret Key (
cron_secret_key) for that specific import (or leave blank to use the Global token). - Copy the command shown in the External Cron Configuration Guide inside Import Settings.
- Add it to your server cron with your desired schedule (for example, every 15 minutes):
cron
*/15 * * * * /usr/bin/curl -s "https://yoursite.com/index.php?rest_route=/nextgen-importer/v1/cron/process&token=YOUR_IMPORT_SECRET_KEY" > /dev/null 2>&1- Only imports matching
YOUR_IMPORT_SECRET_KEY(plus pending image queue items) will run when this cron fires.
Option B: WP-Cron Scheduled Import (No Server Crontab Required)
- In the plugin UI, configure the import's schedule interval (e.g., Hourly, Twice Daily, Daily) via the Schedule workflow (
/schedule). - WordPress schedules
nextgen_run_scheduled_import_hookfor thatimport_id. - Note for low-traffic sites: WP-Cron only fires on incoming site visits unless you also ping
wp-cron.phpor use Option A (External Cron).
3. Comparison Summary
| Feature | Background Cron (Global) | Event-Specific Cron (Per-Import) |
|---|---|---|
| Token Used | Global cron.secret_key |
Per-import cron_secret_key (or WP-Cron import_id hook) |
| Scope | All due/queued imports (without override) + image queue | Only the matching import (+ image queue) |
| Media Queue | Processed automatically (NextGen_Image_Processor) |
Processed automatically on /cron/process |
| Daily Cleanup | nextgen_importer_daily_maintenance (WP-Cron) |
Handled by background retention worker |
| Best For | One master * * * * * cron handling all site imports & images |
Dedicated schedules, isolated client feeds, or webhook triggers |
4. Essential Checklist for Both Modes
- Always use
index.php?rest_route=/nextgen-importer/v1/cron/process&token=...(with&token=, never a second?token=). - Always wrap the URL in double quotes
"..."incrontab -eso&is not interpreted by the shell. - Click Save Settings after generating or changing a Global or per-import token so the database matches your cron command (otherwise
/cron/processreturns403 Forbidden).