How to run WP-CLI in the background
If you have a lot of images to resize, you can run WP-CLI in the background so you don't need to wait for the process to finish. In this quick guide, I'll show you how you can run the command wp media regenerate
in the background:
Install WP-CLI
Open your server terminal
Type the command
nohup wp media regenerate --yes
followed by&
This will run regeneration in the background and print the process identifier number of the job:
To view regenerated thumbnails log, type:
To list running jobs, type the command jobs
The output will be similar to this:
To stop regeneration, use the command kill
and the job number in [1]+
Note: If you ended the terminal session, you will need to use the command ps -eaf | grep wp
instead of jobs
to list running jobs:
The output will be similar to:
To terminate the job process, use the identifier number to terminate it:
Last updated