# Cron jobs

> How WP Waterfall runs WordPress cron from the server, how to schedule your own WP-CLI commands, pause or delete them, and read what each run did.

Source: https://docs.wpwaterfall.com/cron-jobs

WP Waterfall runs WordPress cron from the server, not on page loads. On live, the server runs due events every 15 minutes. To add your own scheduled WP-CLI commands, open the site, then **Tools**, turn on the **Server cron** card, and choose **Cron**.

Needs WordPress on the environment. See [Run a site without WordPress](https://docs.wpwaterfall.com/run-a-site-without-wordpress).

## How does cron run?

- **WordPress cron runs from the server.** WP Waterfall writes `define('DISABLE_WP_CRON', true);` in `wp-config.php` on every environment, so visiting a page never starts it. On live, the server runs `wp cron event run --due-now` every 15 minutes. Each site has its own minute and a short random delay. Scheduled posts, plugin tasks, and WooCommerce actions can start up to 15 minutes late. A run that takes more than 10 minutes is stopped.
- **Your jobs run the same way.** Each job is one WP-CLI command, run as your site's own user (never root) from the site root. If a run is still going when the next is due, the next one is skipped. A run that takes more than an hour is stopped.
- **Everything is logged.** Every run adds a line to **cron.log** on the **Logs** tab: when it finished, how long it took, its exit code, and the end of its output. A failed run is marked as an error.

Staging and preview environments start with WordPress cron off, because they begin as a copy of live data and could send scheduled mail or take subscription renewals a second time. Your jobs on live are not copied to them either. Cron jobs belong to one environment and stay in place when you promote, launch live, clone, or restart PHP.

## What does the Cron tab show?

While Server cron is off, the **Cron** tab is hidden from Tools. An environment that already has cron jobs keeps the tab. The **Schedule** card names the cron that runs WordPress's tasks:

| Shown | Meaning |
| --- | --- |
| **Server cron** | A schedule on the server runs the due tasks. This is live, and any environment where you added a job or turned on Server cron. |
| **WordPress cron** | WordPress runs its tasks on page visits. You should see this only if `wp-config.php` was changed outside WP Waterfall. |
| **Not running** | No cron runs, so scheduled tasks do not run. This is how staging and previews start. |

Below it, the **Cron jobs** list shows each job with its schedule in plain words, its last run, and its status. A row's menu has **Run output**, **Edit**, **Pause** or **Resume**, and **Delete**.

## How do I turn on Server cron for an environment?

Turn on the **Server cron** card in **Tools**, or the button on the Schedule card. WP Waterfall adds one job, described as made by the Server cron tool, that runs `cron event run --due-now` every 15 minutes. If a job of your own already runs `cron event run`, it adds no second one. Turning it off removes that job. On live, the standard 15 minute run comes back.

The interval is not a customer setting. If you need it faster or slower, ask support. To run WordPress's events on your own schedule, add a job whose command is `cron event run --due-now` and pick its schedule: it replaces the built-in run, and on live deleting it brings the built-in run back.

To run cron from another server, request `https://your-site/wp-cron.php?doing_wp_cron` every 15 minutes with `curl` or an uptime monitor. WP Waterfall's own schedule does not need this.

## How do I add a cron job?

1. Choose **Add cron job**.
2. Pick when it runs. Use the schedule builder for common times, or the cron expression field for anything else. Times use UTC.
3. Enter one WP-CLI command, with or without the `wp` prefix, such as `transient delete --expired` or `option get blogname`.
4. Save.

A job can run at most once every 5 minutes and may start up to 45 seconds late. WP Waterfall refuses a faster schedule and says why. Each environment holds up to 100 jobs.

### Which commands can a job run?

Any command the [WP-CLI tool](https://docs.wpwaterfall.com/tools-wp-cli) allows, and nothing else. No pipes, redirects, `&&`, `;`, backticks, or `$( )`. No `php` scripts, and no `wp eval` or `wp eval-file`. WP Waterfall checks the command when you save it and again on the server, so nothing you type is read by a shell. To run your own PHP on a schedule, put the code in a plugin and schedule it with `wp cron event schedule`; the 15 minute run starts it.

On live in Git mode, a job that would install, update, delete, or activate a plugin or theme is refused, the same as in the WP-CLI tool. Make those changes on staging and push them.

A job with `db query` or `db export` follows the rule of the WP-CLI tool: it needs the credentials permission and a sign in confirmed in the last 10 minutes, because the output and the dump can hold password hashes. Anyone who manages cron can still pause or delete it.

## What does the status mean?

| Status | Meaning |
| --- | --- |
| Healthy | The last run exited with code 0, and no run is overdue. |
| Last run failed | The last run exited with a code other than 0. The row shows the last error line. |
| Missed a run | A run was due more than 10 minutes ago and did not happen. |
| Not allowed | The command is not an allowed WP-CLI command, so it never runs. Edit it. |
| Paused | The job is off. |
| Waiting for first run | The job has not run yet. |

When WordPress cron fails or stops, a warning appears above the Schedule card with the reason. WP Waterfall repairs a stopped cron on its own and tells support if the repair fails. A failed run, a missed run, and a stalled cron also add a notice to the bell, once per problem. You can turn these off under the **Site status and health** notifications. If a job does not run, see [Cron job is not running](https://docs.wpwaterfall.com/troubleshooting-cron-not-running).

## How do I pause, read, or delete a job?

- **Pause** from the row menu. A paused job keeps its schedule and command but does not run. Choose **Resume** to start it again.
- **Run output** opens the last run in a side panel: the exit code, the output, and when it is removed. Output is kept 7 days. The summary line stays in **cron.log** longer.
- **Delete** asks you to type the job's description to confirm.

## API

- `GET`, `POST /v1/environments/{id}/cron`, and `PATCH`, `DELETE /v1/environments/{id}/cron/{cron_id}`
- `PUT /v1/environments/{id}/tools/server-cron` with `{"enabled": true}` or `{"enabled": false}`. The MCP tool `set_server_cron_enabled` does the same.
- `GET /v1/environments/{id}/cron` returns `wp_cron.method` (`server`, `wordpress`, or `none`), `wp_cron.server_cron_enabled`, and `wp_cron.interval_minutes` (read only).
- `GET /v1/environments/{id}/logs/{file}`, with `file` set to `cron`

A schedule faster than every 5 minutes or a command that is not allowed answers 422 with an explanation.

## Related

- [Run WP-CLI commands](https://docs.wpwaterfall.com/tools-wp-cli)
- [View logs](https://docs.wpwaterfall.com/logs-viewer)
- [Cron job is not running](https://docs.wpwaterfall.com/troubleshooting-cron-not-running)
- [Jobs and progress](https://docs.wpwaterfall.com/jobs-and-progress)
