This the multi-page printable view of this section.Click here to print.

Return to the regular view of this page.

Remove an existing Schedule

Table of Contents

The AddFunc, AddJob and Schedule functions return two values, an EntryID and an error. If error is nil then the EntryID can be stored and used to cancel the Schedule at a later time.

 1func (p *Example) Start() error {
 2    id, err := p.cron.AddFunc("0 30 * * * *", p.tick)
 3    if err != nil {
 4        return err
 5    }
 6
 7    // Pointless but cancels the timer
 8    p.cron.Remove(id)
 9    return nil
10}
11
12// tick is called every hour on the half hour
13func (p *Example) tick() {
14    // Do something
15}