# Run your own scripts

`cady script` runs your own scripts by registered name, on a cadence if you want, and keeps a journal of every run.

The CLI is not released yet; see [Install the CLI](https://cadyworks.com/docs/install.md).

```sh
cady script add weekly-report --every 1h --local-only -- /home/you/bin/report.sh
cady script run weekly-report
cady script status
```

`add` records the script’s absolute path and pins its contents. `run` starts it and journals the run. `status` prints the journal as JSON, offline. A script is only ever run by name, never by path.

- `--every 1h` or `--cron '*/15 * * * *'` sets a cadence. The scheduled `cady sync` job starts due scripts, so the grain is five minutes.
- `--env NAME` lets the script read one environment variable. It gets `PATH`, `CADY_COMPANY` and the names you declare, nothing else.
- `--param KEY=REGEX` allows a run-time value, as in `cady script run NAME KEY=value`.
- `--timeout SECONDS` stops a run that takes too long. `--lock` refuses a second run while one is going.
- `--local-only` opts out of remote starts. Remote starts are not built yet.

`cady script list`, `remove NAME` and `check [NAME]` complete the set.

## What can go wrong

- A changed file refuses to run until you register it again with `cady script add NAME --replace -- /path`.
- A script that other users can write to is refused.
- Exit codes: 0 completed, 1 failed, 2 configuration, 3 uncertain, 124 timed out, 127 not started. A crashed run is marked uncertain and is never replayed.

Next: [Upload files and export CRM data](https://cadyworks.com/docs/files-and-crm.md)
