Remove an existing Schedule

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}

Last modified October 15, 2021: Switch print page breaks to css (d15ab85)