cron icon indicating copy to clipboard operation
cron copied to clipboard

Multiple executions of scheduled function when laptop is waked up

Open diafour opened this issue 5 years ago • 1 comments

Hello! It seems that I ran into the opposite of https://github.com/robfig/cron/issues/154. I use cron in the program that starts shell scripts on a schedule. Sometimes the program remains in the background and I close the laptop. Several hours later, after the night, the laptop is waked up and the CPU is overloaded because thousands of shell scripts are started %)

The system is Ubuntu 16.04 and the code is like this:

initialization code:

entryId, _ := sm.cron.AddFunc(newEntry.Crontab, func() {
    logEntry.Debugf("fire schedule event for entry '%s'", newEntry.Crontab)
    ScheduleCh <- newEntry.Crontab
})


go routine:

select {
case ev := <-ScheduleCh:
  scripts[ev.Crontab].Start()
...
}

Do you have any idea why cron can execute the callback multiple times after time changes?

diafour avatar Feb 06 '20 20:02 diafour

I'm not sure, but I would like to figure it out and solve this..

robfig avatar Apr 14 '20 17:04 robfig