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

# Cronjobs

> Learn how scheduled prompt and workflow cronjobs work in TeamCopilot.

Cronjobs let TeamCopilot run work on a schedule.

```mermaid theme={null}
flowchart LR
    A[Scheduler fires] --> B{Prompt or workflow?}
    B -->|Prompt| C[Create or resume chat session]
    B -->|Workflow| D[Start workflow run]
    C --> E{Needs user attention?}
    E -->|Yes| F[Pause and surface session]
    E -->|No| G[Continue to completion]
    D --> H[Track workflow run status]
    H --> I[Write run history]
    F --> I
    G --> I
```

## Cronjob types

TeamCopilot supports two cronjob targets:

* **Prompt cronjobs**: scheduled agent chats that can pause for user input
* **Workflow cronjobs**: scheduled workflow runs with structured inputs

## What you can do in the UI

From the Cronjobs tab, users can:

* create a cronjob
* edit an existing cronjob
* enable or disable it
* run it immediately
* delete it
* inspect prior runs

For active runs, users can also open the run detail page and interact with controls such as interrupt, resume, or terminate when those actions are available.

## Scheduling

Cronjobs use a cron expression plus timezone.

The backend validates the schedule and computes the next run time from those settings.

## Prompt cronjobs

Prompt cronjobs create a chat session that the agent can continue over time.

They support:

* an initial prompt
* optional initial todos
* an option to allow workflow runs without extra permission
* pause and resume behavior when the agent needs user attention

Prompt cronjobs are todo-list based. That makes them useful for tasks with many smaller steps, not just one-off prompts.

TeamCopilot keeps the todo list ordered and expects the agent to complete each item in sequence. That helps prevent skipped steps, out-of-order execution, or the agent hallucinating a step that was never part of the plan.

In practice, this means prompt cronjobs can handle fairly complex operational routines as long as the task can be expressed as a clear ordered checklist.

## Workflow cronjobs

Workflow cronjobs run a specific workflow with preconfigured inputs.

They can:

* target a workflow slug directly
* include workflow input JSON
* track workflow run IDs alongside cronjob runs

## Run states

Cronjob runs can be in states such as:

* `running`
* `paused`
* `success`
* `failed`
* `skipped`
* `terminated`

The exact valid states depend on whether the cronjob is prompt-based or workflow-based.

## Runtime controls

For prompt-based runs, the UI can expose:

* interrupt
* resume
* terminate

For workflow-based runs, the UI focuses on the underlying workflow run and its history.

## Handoff behavior

If a prompt cronjob needs help from a user, TeamCopilot can reveal the hidden cronjob chat and pause the auto-continue loop until the user resumes it.

That behavior is what makes cronjobs feel like persistent operational automations rather than fire-and-forget scripts.

## State diagram

```mermaid theme={null}
stateDiagram-v2
    [*] --> Scheduled
    Scheduled --> Running: trigger fires
    Running --> Paused: user attention needed
    Paused --> Running: user resumes
    Running --> Success: completed
    Running --> Failed: error
    Running --> Terminated: user stops
    Running --> Skipped: already active or no-op
```
