# 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:

1. Install [WP-CLI](https://wp-cli.org/#installing)
2. Open your server terminal
3. Type the command  `nohup wp media regenerate --yes`  followed by **`&`**

```bash
$ nohup wp media regenerate --yes &
```

This will run regeneration in the background and print the process identifier number of the job:

```bash
[1] 22699
```

To view regenerated thumbnails log, type:&#x20;

```bash
$ cat nohup.out
```

To list running jobs, type the command `jobs`

```bash
$ jobs
```

The output will be similar to this:

```bash
[1]+  Running                 nohup wp media regenerate --yes & 
```

To stop regeneration, use the command `kill` and the job number in  `[1]+`

```bash
$ kill %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:

```bash
ps -eaf | grep wp
```

The output will be similar to:

```bash
501 22699 22389   0  3:19PM ttys000    0:00.14 wp media regenerate --yes
```

To terminate the job process, use the identifier number to terminate it:

```bash
kill 22699
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sirplugin.com/tutorials/how-to-run-wp-cli-in-the-background.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
