# Recipes

> Save shell scripts as Falak recipes and run them on one or many servers at once, with built-in recipes for caches, packages, disk, memory and ports.

Source: https://falak.sh/docs/guides/recipes/

A **recipe** is a saved bash script that you run on one or more servers through their agents. Output from every server streams into the run page and is kept in the run history.

![Recipes: saved and built-in recipes with a Run action.](./_images/recipes.png)

## Built-in recipes

| Recipe | What it does | Variables |
|---|---|---|
| Clear system caches | `sync`, drop the page cache, `apt-get clean`, vacuum the journal to 7 days, print `free -m` | |
| Install apt package | `apt-get install -y --no-install-recommends $PACKAGE` | `PACKAGE` — space-separated package names |
| Disk usage report | `df -h` and the largest directories under `/var`, `/srv`, `/home` | |
| Memory report | `free -m` and the top processes by memory | |
| Listening ports | `ss -tulpn` | |
| Restart a service | `systemctl restart $SERVICE` and its status | `SERVICE` — a systemd unit |

## Create a recipe

1. Open **Settings → Recipes** and click **New recipe**.
2. Give it a name, an optional description, the Linux **user** to run as, and the script (up to 64 KiB).
3. Save.

## Run a recipe

1. Open the recipe and click **Run**.
2. Pick up to 100 servers, fill in variables, and optionally change the timeout (default 900 s, up to 3600 s).
3. Watch each server's output live. The run finishes when every server finished.

## Permissions

| Action | Permission | Roles |
|---|---|---|
| View recipes and runs | `recipes.view` | all |
| Create, edit, delete | `recipes.manage` | owner, admin, developer |
| **Run** (arbitrary scripts, possibly as root) | `recipes.run` | owner, admin |

A recipe runs whatever it contains on your servers, possibly as root. Keep `recipes.run` for people you would give SSH root access to.

## Limits

- Recipes are covered by unit and feature tests, not yet by the end-to-end suite.

## Next steps
