crontab

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2019 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package crontab provides the ability to run functions once at a given time, every given interval, every given interval after a given time, or every given interval after a given pause. The jobs are added by the different submit commands.

at := time.Date(2018, time.October, 31, 12, 0, 0, 0, time.UTC)
every := 24 * time.Hour

crontab.SubmitAt("id-1", at, func() error {
    log.Printf("I'm executed once at %v.", time.Now())
    return nil
})

crontab.SubmitEvery("id-2", every, func() error {
    log.Printf("I'm executed every 24h. It is %v.", time.Now())
    return nil
})

crontab.SubmitAtEvery("id-3", at, every, func() error {
    log.Printf("I'm executed at %v first, every 24h. It is %v.", at, time.Now())
    return nil
})

crontab.SubmitAfterEvery("id-4", time.Hour, every, func() error {
    log.Printf("I'm executed first after an hour, then every %v.", every)
    return nil
})

Jobs can be deleted with crontab.Revoke(anyID) again.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List() ([]string, error)

List returns all currently submitted IDs.

func Revoke

func Revoke(id string) error

Revoke stops a cronjob and removes it from the table.

func Status

func Status(id string) (notifier.Status, error)

Status returns the status of a cronjob.

func SubmitAfterEvery

func SubmitAfterEvery(id string, pause, every time.Duration, j func() error) error

SubmitAfterEvery adds a function running every interval after a given pause.

func SubmitAt

func SubmitAt(id string, at time.Time, j func() error) error

SubmitAt adds a function running only once at a given time.

func SubmitAtEvery

func SubmitAtEvery(id string, at time.Time, every time.Duration, j func() error) error

SubmitAtEvery adds a function running every interval starting at a given time.

func SubmitEvery

func SubmitEvery(id string, every time.Duration, j func() error) error

SubmitEvery adds a function running every interval.

Types

This section is empty.

Source Files

  • crontab.go
  • doc.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL