# Night queue

A job that needs more memory than the machine has while other jobs run would fail for a reason that is not its own. fleetjobs retries it once when memory frees up. When the retry is killed too, or no memory frees up in time, the job goes to the night queue and `heavy` returns exit 137 with a message that names the job.

## Run it

A timer runs the queue at 02:30. Put this in a systemd user timer, or any scheduler you use:

```sh
heavy night run
```

It runs each queued or accepted job in order, in its working directory, as a `heavy` of its own with `HEAVY_NIGHT_RUN=1`, so a job killed again is not queued again. Each run keeps its output. A job whose working directory is gone is skipped. A job folder is forgotten 14 days after its last change.

## Review it

```sh
heavy night list
heavy night show <id>
heavy night accept <id>
heavy night reject <id>
```

`list` prints one line for each job: its id, state, when it was queued, its folder and its command. `show` prints its state line and the last 60 lines of its output. A queued job runs unless you reject it; `accept` marks it as seen, and a rejected job stays out of the run. Neither changes a job that already ran.

The jobs are folders in the store, `night/<id>/`, with `entry.json` and `out`. The entry keeps the job's command and a few variables from its environment: `PATH`, `LANG`, `LC_*`, `NODE_OPTIONS`, `NODE_ENV`, `CI`, `VITEST_MAX_WORKERS`, `COREPACK_*`, `PNPM_HOME` and `HEAVY_*`.

<!-- vitehub-docs:section-links -->
## In this section

- [Introduction](https://fleetjobs.loadsheet.dev/raw/guide.md)
- [Installation](https://fleetjobs.loadsheet.dev/raw/guide/installation.md)
- [How jobs are placed](https://fleetjobs.loadsheet.dev/raw/guide/placement.md)
- [Remote hosts](https://fleetjobs.loadsheet.dev/raw/guide/hosts.md)
- [Trust](https://fleetjobs.loadsheet.dev/raw/guide/trust.md)
- [Night queue](https://fleetjobs.loadsheet.dev/raw/guide/night.md) (this page)
- [Migrating from the bash heavy](https://fleetjobs.loadsheet.dev/raw/guide/migrating.md)
- [For agents](https://fleetjobs.loadsheet.dev/raw/guide/agents.md)

Next: [Migrating from the bash heavy](https://fleetjobs.loadsheet.dev/raw/guide/migrating.md)

All pages: [llms.txt](https://fleetjobs.loadsheet.dev/llms.txt)

Something on this page does not work as written? Tell the user, and draft an issue for them to post: [issue tracker](https://github.com/words-with-agents/fleetjobs/issues). Report a security vulnerability privately, never in a public issue.
