> ## Documentation Index
> Fetch the complete documentation index at: https://help.noxity.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Cron Jobs

> Run shell commands and PHP scripts on a recurring schedule. The standard Linux cron daemon, with a form to build the schedule expression for you.

Cron Jobs is the cPanel UI for the standard Linux cron daemon. Pick a schedule, paste a command, save. The job runs in your shell environment with your account's permissions.

<Frame caption="cPanel home → Advanced → Cron Jobs">
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/noxity/images/cpanel/advanced/cron-jobs/page-light.png" alt="Cron Jobs page with email field and add-cron form" className="block dark:hidden" />

  <img src="https://mintlify.s3.us-west-1.amazonaws.com/noxity/images/cpanel/advanced/cron-jobs/page-dark.png" alt="Cron Jobs page with email field and add-cron form" className="hidden dark:block" />
</Frame>

## Anatomy of the page

| Section                        | What it does                                                            |
| ------------------------------ | ----------------------------------------------------------------------- |
| **Cron Email** (top)           | Email address that receives any output the job produces. Set this once. |
| **Add New Cron Job**           | The form for building a new schedule and command.                       |
| **Current Cron Jobs** (bottom) | List of jobs already scheduled. Edit or delete from here.               |

## Add a cron job

<Steps>
  <Step title="Pick a preset from Common Settings">
    The dropdown sets all five timing fields at once. Useful presets:

    | Preset                        | Schedule       |
    | ----------------------------- | -------------- |
    | Once a minute                 | `* * * * *`    |
    | Every 5 minutes               | `*/5 * * * *`  |
    | Every 15 minutes              | `*/15 * * * *` |
    | Once an hour                  | `0 * * * *`    |
    | Once a day (midnight)         | `0 0 * * *`    |
    | Once a week (Sunday midnight) | `0 0 * * 0`    |
  </Step>

  <Step title="Or fill the timing fields by hand">
    Five fields: **Minute**, **Hour**, **Day**, **Month**, **Weekday**. Each accepts:

    * A number: `15` (the 15th minute, hour, day, etc.)
    * A range: `1-5`
    * A list: `0,15,30,45`
    * A step: `*/10` (every 10 minutes)
    * `*` for "any value"

    Example: `0 2 * * *` is "minute 0 of hour 2, every day", which means daily at 2:00 AM server time.
  </Step>

  <Step title="Paste the command">
    Anything that runs in your shell. The command runs as your cPanel user, with your account's PATH.

    A few examples:

    ```bash theme={}
    /usr/local/bin/php /home/USER/public_html/cron.php
    ```

    ```bash theme={}
    /home/USER/scripts/backup.sh
    ```

    ```bash theme={}
    cd /home/USER/laravel && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1
    ```

    Replace `USER` with your cPanel username.
  </Step>

  <Step title="Click Add New Cron Job">
    The job appears in the **Current Cron Jobs** table. It runs at the next matching time slot.
  </Step>
</Steps>

## Common cron uses

### WordPress: replace wp-cron.php with system cron

WordPress's built-in `wp-cron.php` runs on every page request, which is wasteful on busy sites. The fix is two-step:

<Steps>
  <Step title="Disable wp-cron.php in wp-config.php">
    Add this line above the `/* That's all, stop editing! */` line:

    ```php theme={}
    define( 'DISABLE_WP_CRON', true );
    ```
  </Step>

  <Step title="Add a system cron to run wp-cron every 5 minutes">
    Schedule: `*/5 * * * *` (every 5 minutes).

    Command:

    ```bash theme={}
    /usr/local/bin/php /home/USER/public_html/wp-cron.php >/dev/null 2>&1
    ```

    Use the path to the actual `wp-cron.php` for your install.
  </Step>
</Steps>

### Laravel scheduler

Laravel ships with a single cron entry that handles all the app's scheduled tasks.

Schedule: `* * * * *` (every minute).

Command:

```bash theme={}
cd /home/USER/laravel && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1
```

Laravel's own `schedule()` definitions in `app/Console/Kernel.php` decide which tasks actually run.

### Daily backup script

Schedule: `0 3 * * *` (3 AM daily).

Command:

```bash theme={}
/home/USER/scripts/backup.sh >> /home/USER/scripts/backup.log 2>&1
```

The output goes to a log file instead of email; useful for keeping a history.

## Pitfalls

<AccordionGroup>
  <Accordion title="My cron isn't running">
    Most common cause: the command's PATH doesn't match your shell PATH. Cron uses a minimal PATH by default, so `php` (without a full path) often isn't found. **Always use the full path** to the binary: `/usr/local/bin/php` for cPanel-managed PHP, or `/opt/cpanel/ea-php83/root/usr/bin/php` for a specific PHP version.

    Other things to check: file permissions on the script (`chmod +x backup.sh`), the script's shebang line, and that the working directory is right (`cd` into it first if your script reads relative paths).
  </Accordion>

  <Accordion title="I'm getting cron output emails I don't want">
    Two options. **First**, redirect output to `/dev/null` in the command itself:

    ```bash theme={}
    /usr/local/bin/php /home/USER/cron.php >/dev/null 2>&1
    ```

    `>/dev/null` drops stdout, `2>&1` drops stderr too. Most production crons do this.

    **Second**, clear the **Cron Email** field at the top of the page to disable email entirely for all jobs. Less surgical, but if you don't care about any cron output, simpler.
  </Accordion>

  <Accordion title="The cron uses the wrong PHP version">
    Cron jobs use the **system default PHP** (`/usr/bin/php`), not your cPanel-selected version. To use the version you set in [Select PHP Version](/web-hosting/cpanel/software/select-php-version/overview), use `/usr/local/bin/php` (the cPanel wrapper). To pin a specific version, use the absolute path: `/opt/cpanel/ea-php83/root/usr/bin/php` (replace `83` with `82`, `81`, etc.).
  </Accordion>

  <Accordion title="The cron behaves differently from when I run the same command in the browser">
    Browser and cron run with different environment variables, working directories, and (often) PHP versions. Cron has no `$_SERVER`, no `$_REQUEST`, and `getcwd()` returns your home directory unless you `cd` first. If your script depends on web-only globals or relative paths, fix the script to handle CLI mode.
  </Accordion>

  <Accordion title="Two crons of the same job started running at the same time and broke things">
    Long-running cron jobs can overlap if a single run takes longer than the schedule interval. Wrap with `flock` to prevent overlap:

    ```bash theme={}
    /usr/bin/flock -n /tmp/myjob.lock /usr/local/bin/php /home/USER/cron.php
    ```

    `-n` means "skip this run if the lock is held". The lock auto-releases when the previous run finishes.
  </Accordion>

  <Accordion title="What's the minimum interval I can schedule?">
    One minute. The cron syntax doesn't support sub-minute intervals. For higher-frequency tasks, write a long-running script that loops with `sleep` and run **that** from cron once a minute, or look at [supervisord](https://docs.litespeedtech.com/) for proper process management.
  </Accordion>
</AccordionGroup>

## Need a hand?

<CardGroup cols={2}>
  <Card title="Open a ticket" icon="life-ring" href="https://members.noxity.io/submitticket.php">
    Best for anything that needs an account check or a config change on our end.
  </Card>

  <Card title="Live chat" icon="messages" href="https://noxity.io/contact">
    Faster for quick questions during business hours.
  </Card>
</CardGroup>
