# Tasks

A task is a command running in a terminal on a machine. It keeps running when every client
disconnects; any client may come back later, read its output and stop it.

## What a task is

- **Started by a call**, `task_start`, from an agent, your backend or the page. It returns an id at
  once.
- **Seen by everyone alike.** The page, MCP and HTTP show the same tasks with the same output, and
  `tasks_list` names who started each.
- **Read as a screen.** `task_output` returns what the terminal shows, as text, whether the task
  still runs or has ended.
- **Stopped on purpose**, with `task_stop`, or when the machine is paused or its program stops.

## Task or one-shot command

| Use | When |
|---|---|
| `exec_run` | the command ends within 10 minutes and you need its exit code |
| `task_start` | a server, a watcher, a long build, anything interactive, or work that should outlive the conversation |

The machine keeps the output of its last 50 tasks until it restarts. A restart stops every task,
and the page lists them as lost.

## Related

[Run commands and long tasks](https://docs.cmdop.ai/guides/run.md) · [The record of calls](https://docs.cmdop.ai/concepts/audit-and-history.md)
