# Cron previous runs

`cron-previous-runs` · version 1.0.0 · Other utilities · free, no key needed

Compute the previous requested UTC fire times for a five-field cron schedule and echo the supplied reference instant.

**Use when you need to: previous cron runs · calculate earlier cron fire times · when did this cron run before.**

## Decide before calling

Read the [versioned contract](/v1/tools/cron-previous-runs/versions/1.0.0) and the supported scope below. Reuse `cron-previous-runs@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `cron-previous-runs@1.0.0` for previous cron runs. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- previous cron runs
- calculate earlier cron fire times
- when did this cron run before
- find past schedule executions
- cron times before an instant
- evaluate cron backward in UTC

## Not supported

- six-field cron with seconds
- named months or weekdays
- IANA time zone daylight-saving rules

## Behavior

- Vixie wildcard status is true when a field starts with *, including */n; if either day field starts with *, both day value sets must match; otherwise day matching uses OR.
- Uses POSIX.1-2024 crontab utility INPUT FILES section five-field ordering; two restricted day fields use OR matching.
- Supports Vixie cron 3.0pl1 list, inclusive range, and step extensions.
- Runs are strictly before reference_instant, returned as UTC minute instants; offset defaults to Z.
- The supplied reference_instant is echoed unchanged and the host clock is never read.

## Input

- `expression` (string, required): min length 1; max length 128
- `reference_instant` (string, required): min length 20; max length 20; pattern `^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$`
- `count` (integer, required): min 1; max 32
- `offset` (string, optional): min length 1; max length 6; pattern `^(Z|[+-]\d{2}:\d{2})$`

## Output

- `expression` (string, required): min length 1; max length 128
- `reference_instant` (string, required): min length 20; max length 20; pattern `^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$`
- `offset` (string, required): min length 1; max length 6; pattern `^(Z|[+-]\d{2}:\d{2})$`
- `runs` (array of string, required): min items 1; max items 32; each min length 20; each max length 20; each pattern `^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$`
- `standard_version` (constant "POSIX.1-2024 crontab utility, INPUT FILES", required)

## Limits

- max input bytes: 512
- max expression bytes: 128
- max results: 32
- max search minutes: 527040
- max output bytes: 4096

## Example

Request input:

```json
{
  "expression": "15 * * * *",
  "reference_instant": "2026-01-01T00:00:00Z",
  "count": 2
}
```

Response:

```json
{
  "result": {
    "expression": "15 * * * *",
    "reference_instant": "2026-01-01T00:00:00Z",
    "offset": "Z",
    "runs": [
      "2025-12-31T23:15:00Z",
      "2025-12-31T22:15:00Z"
    ],
    "standard_version": "POSIX.1-2024 crontab utility, INPUT FILES"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "cron-previous-runs",
  "version": "1.0.0",
  "input": {
    "expression": "15 * * * *",
    "reference_instant": "2026-01-01T00:00:00Z",
    "count": 2
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/cron-previous-runs/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"expression":"15 * * * *","reference_instant":"2026-01-01T00:00:00Z","count":2}'
```

The machine-readable contract is at [/v1/tools/cron-previous-runs/versions/1.0.0](/v1/tools/cron-previous-runs/versions/1.0.0).

### CLI

```sh
node cli.mjs run cron-previous-runs 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Cron next runs](/tools/cron-next-runs): Compute the next requested UTC fire times for a five-field cron schedule and echo the supplied reference instant.
- [Base64url validate](/tools/base64url-validate): Check canonical base64url syntax and return validity plus the first invalid character when present.
- [Cron expression validate](/tools/cron-expression-validate): Check whether a five-field cron expression is supported and return a validity flag with a reason code.
- [Stats percentile](/tools/stats-percentile): Compute an exact percentile from decimal strings using a named Hyndman-Fan type 1 through 9.
- [Array duplicates find](/tools/array-duplicates-find): List duplicated JSON values with counts and first indexes, preserving first-seen order.
- [Array set difference](/tools/array-set-difference): Return unique left-array values absent from the right array, in first-seen order.
