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

# Cron Jobs: Run Commands on a Schedule

> Schedule commands for your PHP, Python or Node.js app, such as a framework's scheduler or a cleanup script. Jobs run as your app's own user in its sandbox.

Cron jobs run a command of your app on a schedule. Use them for a framework's scheduler (Laravel's `schedule:run`, EspoCRM's `cron.php`), queue workers that should run every minute, or cleanup scripts.

Cron jobs are available for PHP, Python and Node.js apps. Static sites (HTML, React and static Next.js) have no app process to run.

## Add a cron job

1. Open your app and go to **Settings**, then **Cron jobs**.
2. Click **Add cron job**.
3. Choose a schedule, or **Custom schedule** to write a cron expression.
4. Enter the command, for example `php -f cron.php`.
5. Check the time zone and the time limit, then click **Save**.

### Paste a crontab line

Many apps print a ready-made crontab line in their install guide, for example EspoCRM:

```
* * * * * cd /opt/servbase/apps/php/<app id>; /usr/bin/php -f cron.php > /dev/null 2>&1
```

Paste the whole line into **Paste a crontab line** and Servbase fills in the schedule and the command for you to check:

* A `cd` into your app folder is removed, because jobs already start there; a `cd` into a folder inside your app becomes a relative one.
* A fixed path such as `/usr/bin/php8.3`, `/usr/bin/node` or `/usr/bin/python3` becomes `php`, `node` or `python`, so the job uses your app's chosen version.
* When the line has no PHP path before `-f` (some guides leave it empty), `php` is added.

Nothing is saved until you click **Save**, and the line is checked the same way as a job you type.

The command runs from your app folder, so use paths relative to it. You do not need `cd` to the app folder or the full path to `php`, `node` or `python`.

| App type | Example command |
| - | - |
| PHP (EspoCRM) | `php -f cron.php > /dev/null 2>&1` |
| PHP (Laravel) | `php artisan schedule:run` |
| Python (Django) | `python manage.py clearsessions` |
| Node.js | `node scripts/cleanup.js` |

## Schedules

A schedule has five fields: minute, hour, day of the month, month and day of the week (0 or 7 is Sunday).

| Expression | Runs |
| - | - |
| `* * * * *` | Every minute |
| `*/5 * * * *` | Every 5 minutes |
| `0 * * * *` | Every hour, on the hour |
| `30 2 * * *` | Every day at 02:30 |
| `0 9 * * 1-5` | Weekdays at 09:00 |
| `0 0 1 * *` | The first day of every month at midnight |

Each field accepts `*`, a number, a range (`1-5`), a list (`1,15`) and a step (`*/10`, `0-30/10`). `@hourly`, `@daily`, `@weekly`, `@monthly` and `@yearly` also work. Names such as `MON` or `JAN` are not accepted.

Times are in the job's time zone (your workspace's default is shown when you add a job). The page shows when each job runs next.

## How jobs run

* **Your app's own user.** A job runs as the same user as your app and its terminal, never as an administrator. It cannot use `sudo`, gain privileges or see other apps and their processes.
* **Your app's settings.** It gets your app's variables (and secrets), and runs with your app's PHP version, Node.js version or Python virtualenv.
* **A time limit.** A job is stopped with everything it started when it reaches its time limit (5 minutes by default, at most 15).
* **No overlaps.** If a run is still going when the job is due again, that time is skipped.
* **Only while your app runs.** Jobs of stopped, paused or not yet deployed apps do not run.

Each app can have up to 10 cron jobs. Each server runs a few jobs at a time; a job that finds its server busy is skipped until its next time, and its history says so.

## History and Run now

**History** shows the status, exit code and output of a job's last 20 runs. A run is **success** when the command exits with 0, **failed** otherwise, **timeout** when it reached the time limit, and **skipped** when it could not start.

**Run now** runs a job once right away, which is useful to test a new command. **Pause** stops a job from running on its schedule until you resume it.

> [!NOTE]
>
> Output can include sensitive values your command prints. Only workspace members who can manage the app can see cron jobs and their output.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.