Technology
Run Scheduled Jobs
Ask AI
How Corridor's built-in scheduler works, how to configure its check interval, and how to trigger scheduled jobs manually or with an external scheduler.
Corridor provides an in-built scheduler to schedule and run jobs. The scheduler checks at regular intervals if any job has been scheduled by the user to run by that time and starts the execution.
The user has the ability to run any or all the scheduled jobs by using the run-scheduled-jobs utility by specifying
the corresponding options.
The command with available option:
$ corridor-api scripts run-scheduled-jobs --help
Usage: corridor-api scripts run-scheduled-jobs [OPTIONS]
Command to run scheduled jobs which need to be run before `execution-time`
Options: --job-id INTEGER Job ids to check if needed to run --execution-time TEXT Time by which the scheduled jobs are run --help Show this message and exit.By default, the Corridor scheduler is enabled.
Scheduling configurations in Corridor
Section titled “Scheduling configurations in Corridor”The scheduler can be configured to check for scheduled jobs at any interval of time. We would need to do the appropriate
configurations in the api_config.py file.
# Refer(for format): https://docs.celeryproject.org/en/v4.0.0/reference/celery.schedules.html#celery.schedules.crontabfrom celery.schedules import crontabCORRIDOR_CRON_SCHEDULE = crontab('*/30', '*', '*', '*', '*')Using external schedulers
Section titled “Using external schedulers”The user has the option to use external schedulers to run scheduled jobs, based on the requirements.
The external scheduler could be a simple cron job.
Example
Section titled “Example”To run all jobs scheduled to run by 2020-01-01 midnight:
corridor-api scripts run-scheduled-jobs --execution-time 2020-01-01:00:00:00There would not be any output generated from the command, but the scheduled jobs will start getting executed.
Was this page helpful?
Thanks for the feedback.