Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]Expose entryID for job #29

Open
halfcrazy opened this issue Feb 20, 2020 · 3 comments
Open

[Feature Request]Expose entryID for job #29

halfcrazy opened this issue Feb 20, 2020 · 3 comments

Comments

@halfcrazy
Copy link

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

@jiangytcn
Copy link

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

@Yc1883896
Copy link

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

@Ctere1
Copy link

Ctere1 commented Jun 14, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants