cron

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cron

type Cron struct {
	Host     string  `json:"host"`
	User     string  `json:"user"`
	TimeZone string  `json:"timezone"`
	Count    int     `json:"task_count"`
	Tasks    []*Task `json:"tasks"`

	File string `json:"-"`
	// contains filtered or unexported fields
}

Cron represents the info of crontab

var CronTab Cron

CronTab is a global singleton object

func (Cron) FindTaskByID

func (c Cron) FindTaskByID(id int) *Task

FindTaskByID returns the task pointer with specified task id

func (*Cron) GetReportIDs

func (c *Cron) GetReportIDs() error

GetReportIDs walks through cache dir and parse existing execution report, save it to reportIDs

func (*Cron) Parse

func (c *Cron) Parse()

Parse parses cron file into Cron struct

func (*Cron) SetHost

func (c *Cron) SetHost(hostname ...string)

SetHost sets host info to c.Host. If param hostname exists, set c.Host to hostname

func (*Cron) SetTimeZone

func (c *Cron) SetTimeZone(tz ...string)

SetTimeZone sets timezone info to c.TimeZone. If param tz exists, set c.TimeZone to tz

type Task

type Task struct {
	ID        int            `json:"id"`
	Title     string         `json:"title"`
	Schedule  string         `json:"schedule"`
	Command   string         `json:"command"`
	NextRun   time.Time      `json:"next_run"`
	Report    *report.Report `json:"report,omitempty"`
	Checksum  string         `json:"checksum"`
	IsChanged bool           `json:"is_changed_since_lastrun"`
}

Task represents one task of crontab

func (*Task) Load

func (t *Task) Load()

Load reads the execution report of current task

Jump to

Keyboard shortcuts

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