How do I check the Next Run of a Job on the Scheduler? #246
-
Greetings, while trying to get the time of the Next Run of a job I keep getting a SIGSEGV. This is a somewhat simplified version of the code: sched := gocron.NewScheduler(time.Local)
func initTasks() {
if constants.ENVIRONMENT == "Prod" {
t1, _ := sched.Cron("* 18 ? * MON").Do(task1)
sched.StartAsync()
utils.Log.Debug(t1.NextRun())
}
} When it runs the logger with
What is it that I'm doing wrong? Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @vinicius507 you have the right idea here. I am wondering if something inside your code (the logger, or the task itself) is throwing that seg fault. I made a simple example showing the next run with that cron schedule and it prints out just fine: func main() {
sched := gocron.NewScheduler(time.Local)
job, err := sched.Cron("* 18 ? * MON").Do(func() {})
if err != nil {
log.Fatal(err)
}
sched.StartAsync()
log.Println(job.NextRun())
} Have you tried running with a debugger to see where it's hitting that issue? Or just putting in some fmt.Println statements to see how far it's getting before hitting that seg fualt?`` |
Beta Was this translation helpful? Give feedback.
Hi @vinicius507 you have the right idea here. I am wondering if something inside your code (the logger, or the task itself) is throwing that seg fault. I made a simple example showing the next run with that cron schedule and it prints out just fine:
Have you tried running with a debugger to see where it's hitting that issue? Or just putting in some fmt.Println statements to see how far it's getting before hitting that seg fualt?``