# SSH Snippets & Scheduled Commands

**Snippets** are Tempest's saved shell commands — paste a command once, give it a name, and re-run it on any host with a click. **Scheduled runs** turn snippets into cron jobs that fire on the hosts you choose, with notifications routed to your phone via [Tempest Push](/productivity/tempest-push-notifications.md) when a run fails.

It's the missing layer between "I keep retyping the same `journalctl -u …`" and "I don't want to set up Ansible just for three commands."

## Save a snippet

1. Open the **Snippets** panel.
2. Click **New Snippet**.
3. Paste your command (multi-line is fine — bash heredocs, pipelines, etc.).
4. Give it a name and optionally a description.
5. Save.

Snippets sync across your devices via your encrypted vault, just like hosts.

## Run a snippet

* In any SSH tab, open the snippet panel and pick one — Tempest sends it through the channel
* Or **target multiple hosts** at once: pick the snippet, select hosts from your list, run. Each host gets its own output panel.

## Schedule a snippet

1. Open a snippet → **Schedule** tab.
2. Set the cron expression (UI helper for common patterns: every hour, every day at 3 AM, etc.).
3. Pick targets: one host, a tag-matched group, or all hosts.
4. Optional: enable **Notify on failure** → exit code ≠ 0 triggers a Tempest Push to your phone.
5. Save.

The schedule runs **in the Tempest backend** (Electron main process / standalone server), not in the renderer. So:

* Your laptop can be asleep and the run still happens — as long as the Tempest backend is up.
* On the **standalone Tempest server**, schedules survive even if no client is connected (perfect for lightweight ops automation).

## Run history

Each scheduled run records:

* Start / end timestamp
* Exit code
* Stdout / stderr captured (configurable size limit)
* Per-target status when running fan-out

Browse history in **Snippets → History** with filters by snippet, host, and status.

## When to use snippets vs. an actual config-management tool

| Use Snippets when                                                       | Use Ansible / Puppet / Salt when                  |
| ----------------------------------------------------------------------- | ------------------------------------------------- |
| 1–10 hosts                                                              | Hundreds of hosts                                 |
| Operational commands ("show me the disk usage", "restart this service") | Declarative state ("nginx must be installed")     |
| You want one-shot fan-out from your laptop                              | You want a CI pipeline triggering converged state |
| Quick fix for a specific incident                                       | Reproducible infrastructure                       |

The two complement each other — snippets handle ad-hoc operational tasks, real config-management tools handle long-lived state.

## Pro feature

Scheduled runs are part of **Tempest Pro**. Saving and one-off running of snippets is free.

## See also

* [Tempest Push Notifications](/productivity/tempest-push-notifications.md) — how failure alerts reach your phone
* [Tempest AI Assistant](/productivity/tempest-ai-assistant.md) — generate snippet content from a natural-language description


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gotempest.app/productivity/snippets-scheduled-runs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
