# Scheduled Tasks

Scheduled tasks save a conversation instruction for later execution. Create them in conversation by specifying the task, schedule, and target device; use an online MQTT, SDK, or simulated device when the task reads state or sends commands.

## Create a Task

In a Device Agent workspace, select the target device and enter a natural-language request:

```text
In 1 minute, set the current thermostat target temperature to 24°C.
```

The Device Agent stores the request as a one-shot, fixed-interval, or `cron` schedule and returns the next run time.

| Task type | Example |
| --- | --- |
| Delayed run | `In 1 minute, set the current thermostat target temperature to 24°C.` |
| Fixed interval | `Every 5 minutes, check the current temperature. If it is above 30°C, set the target temperature to 24°C.` |
| Daily run | `Every morning at 9 AM, switch the current thermostat to eco mode.` |

![Scheduled task conversation](../images/docs/usage/scheduled-tasks/en/01-scheduled-task.png)

## Check Execution

When a scheduled task fires, the gateway starts an isolated run with a `cron:<timerId>` session ID. Use the `Timer` module records in [Logs](../operate-reference/logs.md) as the source of truth:

```text
[14:27:17] [INFO ] [Timer] Scheduled task 8362d16a-e712-4f4d-9d08-caaa6a88f7eb fired {"timerId":"8362d16a-e712-4f4d-9d08-caaa6a88f7eb","scheduleKind":"once","scheduleExpr":"1m","status":"fired"}
[14:27:21] [INFO ] [Timer] Scheduled task 8362d16a-e712-4f4d-9d08-caaa6a88f7eb completed {"timerId":"8362d16a-e712-4f4d-9d08-caaa6a88f7eb","scheduleKind":"once","scheduleExpr":"1m","status":"complete"}
```

If execution fails, the same `timerId` appears with `status:"error"`. When the web console is open, it also shows live notifications for started, completed, and failed tasks. The **View logs** action opens the logs page with the current `timerId` already applied as a filter.

If the original conversation can still receive replies, the result may appear there. If it cannot, the gateway ignores that conversation reply. The `Timer` logs still record the trigger and terminal status.

## List and Cancel Tasks

Manage scheduled tasks from the conversation:

```text
List my active scheduled tasks.
```

```text
How long until the target-temperature task I just created runs?
```

```text
Cancel the target-temperature task I just created.
```

If multiple tasks could match, list them first and then cancel by task ID or a clear task description. Canceled tasks are marked deleted and no longer fire. Cancel recurring tasks when they are no longer needed.

## Verify Device Actions

A scheduled task only wakes the Device Agent at the requested time. To confirm that a device action took effect, check device state, device logs, or MQTT messages. Device control still has to resolve to commands defined in the DeviceSpec.
