jobrunner icon indicating copy to clipboard operation
jobrunner copied to clipboard

[Feature Request]Expose entryID for job

Open halfcrazy opened this issue 5 years ago • 3 comments

When scheduling a job, I expected to get an entryID for this job, so I can remove this job later.

halfcrazy avatar Feb 20 '20 02:02 halfcrazy

you can use jobrunner.StatusPage() to extract entry id

jiangytcn avatar Apr 09 '20 02:04 jiangytcn

jobrunner.StatusPage() 没有办法灵活的停止某个任务,当创建了两个同样函数的任务时,并无法进行精确的定位我要删除哪一个, 既然MainCron.Schedule(sched, New(job))公开了entry id,那么应该也有相应的返回

Yc1883896 avatar Sep 08 '20 06:09 Yc1883896

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
    }
}

Ctere1 avatar Jun 14 '24 17:06 Ctere1