# dokploy_schedule (Resource)

A cron job Dokploy runs against a service, a remote server, or the Dokploy host itself.

## Example Usage

```terraform
# Nightly cleanup inside an application's container.
resource "dokploy_schedule" "prune" {
  name            = "nightly-prune"
  schedule_type   = "application"
  service_id      = dokploy_application.web.id
  cron_expression = "0 3 * * *"
  command         = "node scripts/prune.js"
  timezone        = "Africa/Johannesburg"
}

# A job on the Dokploy host itself takes no service_id.
resource "dokploy_schedule" "host_df" {
  name            = "disk-report"
  schedule_type   = "dokploy-server"
  cron_expression = "0 8 * * 1"
  shell_type      = "sh"
  command         = "df -h /"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `command` (String) Command to run.
- `cron_expression` (String) Standard five-field cron expression, e.g. `0 3 * * *`. Dokploy does not validate it at write time; a malformed expression simply never fires.
- `name` (String) Display name.
- `schedule_type` (String) What the job runs against: `application`, `compose`, `server`, or `dokploy-server`. `dokploy-server` runs on the Dokploy host itself and takes no `service_id`. Changing this forces replacement.

### Optional

- `description` (String) Free-form description.
- `enabled` (Boolean) Whether the job runs. Defaults to `true`: Dokploy leaves this null when a schedule is created through the API alone, which is neither on nor off, and a schedule declared in configuration that silently never fires is the worse failure.
- `script` (String) Inline script body, as an alternative to a one-line `command`.
- `service_id` (String) Id of the application, compose service or server this runs against. Required for every `schedule_type` except `dokploy-server`, which has no parent. Changing it forces replacement: Dokploy's update endpoint sets the new parent without clearing the old one.
- `service_name` (String) Name of the specific container to run in, for compose services with more than one.
- `shell_type` (String) Shell the command runs under: `bash` or `sh`.
- `timezone` (String) IANA timezone the cron expression is evaluated in, e.g. `Africa/Johannesburg`. Defaults to the server's timezone.

### Read-Only

- `app_name` (String) Dokploy-internal app name, generated by the server.
- `created_at` (String) Creation timestamp (server-side).
- `id` (String) Schedule id.

## Import

Import is supported using the following syntax:

The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:

```shell
terraform import dokploy_schedule.prune s1a2b3c4d5e6f7g8h9i0j
```