Description
Describe the bug
I start a scheduler in my local timezone. Then I read the scheduled jobs from a struct in settings.
I receive the start time as a json timestamp, which is converted to a Golang Time. In the printed output, it seems like this conversion works the way it should.
Also when I ask when the next scheduled job is going to run, I see the correct time.
Alas, when the time comes to run the job, nothing happens.
If I add a recurring job to the queue, say every 2 seconds, I do see the function getting executed with the parameters that were passed.
I also see the tag, I added to the job.
Any idea what I might be doing wrong?
Jo
To Reproduce
Steps to reproduce the behavior:
`
func main() {
location, _ := time.LoadLocation("Europe/Brussels")
scheduler := gocron.NewScheduler(location)
for _, task := range settings.Schedule {
PrettyPrint(task)
now := nowFormatted()
if task.StartDate > now {
var DateRE = regexp.MustCompile(`/Date\((?P<UnixTimestamp>\d+)(?P<TZOffset>[-\+]\d+)\)`)
tsString := DateRE.FindStringSubmatch(task.StartDate)[1]
timestamp, _ := strconv.ParseInt(tsString, 10, 64)
startTime := time.Unix(timestamp/1000, 0)
job, err := scheduler.Every(1).Day().StartAt(startTime).SetTag([]string{task.ID}).Do(taskWithParams, task)
// scheduler.Every(2).Seconds().Do(taskWithParams, task)
PrettyPrint(tsString)
PrettyPrint(timestamp)
PrettyPrint(startTime.Format("Mon Jan 2 15:04:05 -0700 MST 2006"))
_, tt := scheduler.NextRun()
log.Warn("Next run")
PrettyPrint(tt.Format("Mon Jan 2 15:04:05 -0700 MST 2006"))
if err != nil {
log.Error(err)
}
if task.RecurrencePattern == "" {
job.LimitRunsTo(1)
job.RemoveAfterLastRun()
}
scheduler.StartAsync()
}
`
Output:
{ "Action": 0, "EndDate": "/Date(1608919200000+0100)/", "Filename": "/home/pi/doSomethingImportant.sh", "Id": "8a102123-a91d-474b-8f83-547c9cdcf3ad", "Parameters": "", "ProcedureName": "main", "RecurrencePattern": "", "ScheduleType": 0, "StartDate": "/Date(1608918720000+0100)/" } "1608918720000" 1608918720000 "Fri Dec 25 18:52:00 +0100 CET 2020" WARN[25/12/2020 18:50:35] Next run "Fri Dec 25 18:52:00 +0100 CET 2020" [ "8a102123-a91d-474b-8f83-547c9cdcf3ad" ]