- Notifications
You must be signed in to change notification settings - Fork5.7k
Description
Hi all! I'd like to contribute to this project. I think it would be much easier to work with CRON style job scheduling. Below I describe the idea and list few examples. If this suggestion can be approved and merged I can come up with some integration plan.
Implementation details
defrun_cron(self,callback,tab)
Wheretab
is astring
object representing a standard CRON tab entry.
Functionrun_cron
would throw appropriate exception iftab
object is not a string matching CRON tab entry (use regex validation)
In order to easily integrate it into current scheduler we need to know how much time is required to pass until next execution, then we just add it into the queue with appropriate delay, which itself can be computed usingcroniter.
Few examples below.
Examples
Run callback_function everyday at 2:00 AM.
job=j.run_cron(callback_function,'0 2 * * *')
Run callback_function twice per day, at 5:00 AM and at 5:00 PM
job=j.run_cron(callback_function,'0 5,17 * * *')
Run callback_function every minute
job=j.run_cron(callback_function,'* * * * *')
Run callback_function every Sunday at 5:00 PM ( note that Sunday is both0
and7
)
job=j.run_cron(callback_function,'0 17 * * 0')
Run callback_function every 10 minutes
job=j.run_cron(callback_function,'*/10 * * * *')
Run callback_function every minute but only in January, May and August
job=j.run_cron(callback_function,'* * * 1,5,8 *')
Run callback_function every Friday and Sunday at 5:00 PM
job=j.run_cron(callback_function,'0 17 * * 5,7')