Cron is a crontab-like struct for tasks/jobs scheduling.

Hierarchy

  • Cron

Methods

  • Add registers a single cron job.

    If there is already a job with the provided id, then the old job will be replaced with the new one.

    cronExpr is a regular cron expression, eg. "0 */3 * * *" (aka. at minute 0 past every 3rd hour). Check cron.NewSchedule() for the supported tokens.

    Parameters

    • jobId: string
    • cronExpr: string
    • run: (() => void)
        • (): void
        • Returns void

    Returns void

  • HasStarted checks whether the current Cron ticker has been started.

    Returns boolean

  • MustAdd is similar to Add() but panic on failure.

    Parameters

    • jobId: string
    • cronExpr: string
    • run: (() => void)
        • (): void
        • Returns void

    Returns void

  • Remove removes a single cron job by its id.

    Parameters

    • jobId: string

    Returns void

  • RemoveAll removes all registered cron jobs.

    Returns void

  • SetInterval changes the current cron tick interval (it usually should be >= 1 minute).

    Parameters

    Returns void

  • SetTimezone changes the current cron tick timezone.

    Parameters

    Returns void

  • Start starts the cron ticker.

    Calling Start() on already started cron will restart the ticker.

    Returns void

  • Stop stops the current cron ticker (if not already).

    You can resume the ticker by calling Start().

    Returns void

  • Total returns the current total number of registered cron jobs.

    Returns number

Generated using TypeDoc