Skip to content

Implement CRON style job scheduling #1337

@marekyggdrasil

Description

@marekyggdrasil

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

def run_cron(self, callback, tab)

Where tab is a string object representing a standard CRON tab entry.

Function run_cron would throw appropriate exception if tab 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 using croniter.

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 both 0 and 7 )

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')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions