jobrunner
jobrunner copied to clipboard
[Feature Request]Expose entryID for job
When scheduling a job, I expected to get an entryID for this job, so I can remove this job later.
you can use jobrunner.StatusPage()
to extract entry id
jobrunner.StatusPage() 没有办法灵活的停止某个任务,当创建了两个同样函数的任务时,并无法进行精确的定位我要删除哪一个, 既然MainCron.Schedule(sched, New(job))公开了entry id,那么应该也有相应的返回
You can use like that:
status := jobrunner.StatusJson()
jobs := status["jobrunner"].([]jobrunner.StatusData)
for _, job := range jobs {
if job.JobRunner.Name == "YOUR_JOB_NAME" {
id := job.Id
jobrunner.Remove(id) // Remove YOUR_JOB_NAME by its ID
err := jobrunner.Schedule(YOUR_JOB_NAME, SyncAllUsersJob{}) // Reschedule with new interval
if err != nil {
log.Println(err.Error())
}
break
}
}