cron
cron copied to clipboard
add support for long-term job auto remove inside the job execution
Hi there.
Since the missing support for removing job itself during the job execution , we now facing lots of the ticker leaks for our long-term cronjob. To make another job manager to refresh(or rebuild) the job lists is not easy and seems too heavy for the client-side code .
Could cron add the option job to allow us get the entryID during execution in order to remove the original job so that the ticker will be released.
I also make a pr for my proposal , we'd hope it can be merged into master ASAP.
In other words, you want to schedule the job to run once, and not again?
You can do that today with something like this:
func runOnce(job cron.Job, schedule string)
sched, _ := cron.ParseStandard("...")
now := time.Now()
next := sched.Next(now)
time.Sleep(next.Sub(now))
job()
}
Not exactly , with these option we can not only making a one time job more clear , but introduce a hook-like mechanism to allow users do more things(remove,update, delayed remove or other job lifetime-related operation) with the job entryid .