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

# Set up cron jobs

> Understand how to configure Laravel cron jobs.


Cron jobs allow you to run scheduled tasks at specified times or intervals.

While you can run your own custom tasks, Laravel provides a scheduler to simplify the implementation.
To implement it, see the Laravel [Task Scheduling documentation](https://laravel.com/docs/master/scheduling).

## Set up a cron job

To set up a cron job, update your Upsun Cloud configuration as follows:

```yaml .upsun/config.yaml theme={null}
applications:
  myapp:
    [...]
    crons:
      snapshot:
        spec: * * * * *
        commands:
          start: |
            php artisan schedule:run >> /dev/null 2>&1
```

## Run cron jobs based on environment type

To run a command in a cron hook for specific environment types,
use the `PLATFORM_ENVIRONMENT_TYPE` environment variable:

```yaml .upsun/config.yaml theme={null}
applications:
  myapp:
    [...]
    crons:
      snapshot:
        spec: 0 5 * * *
        commands:
          start: |
            # only run for the production environment, aka main branch
            if [ "$PLATFORM_ENVIRONMENT_TYPE" = "production" ]; then
              php artisan schedule:run >> /dev/null 2>&1
            fi
```

## Run the Laravel scheduler every minute

Cron job execution on the default Upsun Cloud offering are limited to once every 5 minutes.
For more information, see the [documentation on crons](https://developer.upsun.com/docs/configure-apps/image-properties/crons.md).

However, you can add a [worker](https://developer.upsun.com/docs/configure-apps/image-properties/workers.md)
and specify a start command that [runs the scheduler every minute](https://laravel.com/docs/11.x/scheduling#running-the-scheduler-locally).
To do so, use the following configuration:


&#x20;   applications:
&#x20;     \<APP\_NAME>:
&#x20;       \[...]
&#x20;       workers:
&#x20;         scheduler:
&#x20;           commands:
&#x20;             start: |
&#x20;               php artisan schedule:work

> [!WARNING]
>
> Warning
> Web and worker containers don't share mount targets.
> You can't share files between those containers using the filesystem.
> To share data between containers, use [services](https://developer.upsun.com/docs/add-services).


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