1

I have a large wp all import running from from command line daily but I would like to add a step to cancel/stop the previous import prior to running the new round.

For whatever reason we may have had some dirty data, something happened on the server etcd and it crashed the import the previous session, I would like to cancel that import which is still 'running' but not importing for us to then reset it for a new import.

Currently I get 'Error: Import already running.' when we re-run

cd /home/domain.com/public_html/; wp all-import run 1 --allow-root;

I have tried a few variations to stop, cancel, halt etc., but nothing seems to work

How are people handling this?

montrealist
  • 5,593
  • 12
  • 46
  • 68

1 Answers1

0

It looks like currently (plugin version 4.6.5) stopping imports via WP CLI is not supported:

$ wp help all-import

...

SUBCOMMANDS

  list      ## EXAMPLES
  run       ## OPTIONS

You could probably add your own subcommand by using one of the example code snippets:

$import = new PMXI_Import_Record(); 
$import->getById($importID); // user needs to provide ID, much like for 'run' subcommand
$import->set( array( 
    'queue_chunk_number' => 0,
    'processing' => 0, 
    'imported' => 0, 
    'created' => 0, 
    'updated' => 0, 
    'skipped' => 0, 
    'deleted' => 0, 
    'triggered' => 0, 
    'executing' => 0     
))->update();
montrealist
  • 5,593
  • 12
  • 46
  • 68
  • Hey mate Tried this, but it only worked after I formally cancelled the import from within WP So the default cli appears to prevent the logic above cancelling as its already running and can not run an import specific hook – Torn Marketing Mar 18 '21 at 06:05