import-scheduler is a WordPress plugin for sites that import from many sources. It runs each import rule as its own unit of work on a dedicated cron lane, with per-rule last run, next run and duration on one screen and in WP-CLI. It is MIT licensed, and v0.1.0 was released on 15 November 2026.
The usual set-up runs every import rule inside one scheduled hook, with one lock so two passes never overlap. That fails quietly as the rule count grows.
The plugin makes each rule its own unit of work with its own interval, lock and history, and a tick that stops choosing new work when its time budget is spent.
success, failure, overrun, abandoned or lock_lost, a message and a monotonic duration.import_scheduler_register_feed(), that reads one feed through core’s fetch_feed() and emits items on an action. Turning items into posts is the consumer’s job.tick, list, status, run, pause, pause-lane, history, unlock and cron-line.Rules are registered unconditionally on the import_scheduler_register action, so the WP-CLI process that runs the lane sees them too:
add_action('import_scheduler_register', function () {
import_scheduler_register('partner-api', function (\IndianOpinion\ImportScheduler\RunContext $context) {
$response = wp_safe_remote_get('https://example.com/api/items', ['timeout' => 15]);
if (is_wp_error($response)) {
return $response; // failure, with its message
}
// ... import, checking $context->shouldStop() between items ...
return 12; // success, 12 items
}, ['interval' => 600, 'lane' => 'default']);
});
Then one system cron line per lane, printed by wp import-scheduler cron-line --lane=default --user=www-data --path=/var/www/site. Each tick reads the database clock once, runs pre-flight guards, takes a lane slot, finds due rules with one indexed query capped at 200 rows, oldest due first, and runs them one by one until its budget is spent. Rules whose turn did not come stay due and lead the next tick.
A lock is a row with a name, owner token, acquired time, expiry and heartbeat. Taking one is an insert. If the name is taken, a single conditional update takes it over only when it has expired. All lock times come from UNIX_TIMESTAMP() in the statement, so web nodes with skewed clocks agree. There are no lock files, no flock and no MySQL named locks, and a crashed process never wedges a lane for longer than the expiry.
After a success the next run is the scheduled time plus the interval, or now plus the interval if that is past, so there is never a burst of catch-up runs. After an overrun it is the finish plus a full interval. After a failure it is the finish plus the interval times 2 to the power of failures minus 1, capped. Storage is four tables: rules, runs, locks and ticks.
IMPORT_SCHEDULER_DISABLE in wp-config.php wins over the setting. Running rules see shouldStop() turn true. A single lane can be stopped with pause-lane.memory_limit), and optional disk and available-memory floors, below which it stands down.abandoned once its lock expires./dev/null, and to give every HTTP call in a runner a timeout.run had finished, or that an operator had paused or moved, could run again. The runner now re-reads the state row after taking the rule lock and skips the rule if it is no longer due.run <id> on a rule that was not yet due pushed its schedule out by a full interval. The scheduled time is now the smaller of the stored next run and the run’s start.tick now reports missing tables or a database error as an error with exit code 1. Each fix has a regression test that fails on the previous code.--url.Test status: this is v0.1.0. The review reports 74 PHPUnit tests on PHP 8.3, PHPStan level 8 and phpcs clean. One test, the MySQL lock race test, is gated on a database connection and was not run locally, so it is left to a CI job. The other tests use an in-memory double and WordPress stubs. CI has not yet run on GitHub, and the plugin has not run against a live site. It was specified, built and reviewed in separate roles by language-model coding agents under the editor’s direction.
It needs PHP 8.1 or later, WordPress 6.4 or later, WP-CLI 2.8 or later, MySQL 5.7 or later or MariaDB 10.4 or later, and a host where you can add a system cron line.
The package is not on Packagist yet, so first add a Composer vcs repository entry for https://github.com/IndianOpinion/import-scheduler.
composer require indianopinion/import-scheduler
Without Composer, unzip a release into wp-content/plugins/import-scheduler/ and activate it.