Skip to content
Interfaceplugin-tasksv0.1.0-next.1

TaskOptions

The options @RegisterTask takes after a cron pattern.

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

every

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.

every?: ValidDuration<TEvery>

key

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.

key?: string

Default:The class name.

maxRuns

Stops the task after this many runs.

maxRuns?: number

paused

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

paused?: boolean

Default:false

protect

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.

protect?: boolean

Default:true

startAt

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

startAt?: Date | string

stopAt

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

stopAt?: Date | string

timezone

Overrides the plugin's timezone for this task.

timezone?: Timezone<TZone>