# TaskOptions

`interface` in `plugin-tasks` · v0.1.0-next.1

<https://seedcord.org/docs/packages/plugin-tasks/0.1.0-next.1/interfaces/task-options>

The options `@RegisterTask` takes after a cron pattern.

```ts
interface TaskOptions<
    TZone extends string = string,
    TEvery extends string = string
>
```

## Properties

### every

```ts
every?: ValidDuration<TEvery>
```

The shortest gap between two runs as a duration in whole seconds like `'90s'` or `'5m'`. The task
still only runs at times that the pattern matches. For example, `'* * 9-17 * * 1-5'` with
`every: '90s'` runs every 90 seconds during those hours. After `resume()`, the task runs at its
next match, and the gap counts from there.

### key

```ts
key?: string
```

The task's identity in logs, bus events, and stored jobs. Set it on a scheduled task to keep its
pending jobs working through a class rename.

### maxRuns

```ts
maxRuns?: number
```

Stops the task after this many runs.

### paused

```ts
paused?: boolean
```

Starts the task's pattern paused. Call `resume()` to start it. Scheduled tasks and `trigger()`
still run the task.

### protect

```ts
protect?: boolean
```

Skips a cron or manual run before the previous run has finished, and calls `onOverrun()` for it.
A scheduled task waits for the previous run to end. Skipping it would lose the job's data.

### startAt

```ts
startAt?: Date | string
```

The task doesn't run before this date. A pattern match exactly at this date runs.

### stopAt

```ts
stopAt?: Date | string
```

The task doesn't run after this date. A pattern match exactly at this date doesn't run either.

### timezone

```ts
timezone?: Timezone<TZone>
```

Overrides the plugin's `timezone` for this task.
