- class CveXplore.core.celery_task_handler.task_handler.crontab(celery.schedules.BaseSchedule)[source]
Crontab schedule.
A Crontab can be used as the
run_every
value of a periodic task entry to add crontab(5)-like scheduling.Like a cron(5)-job, you can specify units of time of when you’d like the task to execute. It’s a reasonably complete implementation of cron’s features, so it should provide a fair degree of scheduling needs.
You can specify a minute, an hour, a day of the week, a day of the month, and/or a month in the year in any of the following formats:
- minute¶
A (list of) integers from 0-59 that represent the minutes of an hour of when execution should occur; or
A string representing a Crontab pattern. This may get pretty advanced, like
minute='*/15'
(for every quarter) orminute='1,13,30-45,50-59/2'
.
- hour¶
A (list of) integers from 0-23 that represent the hours of a day of when execution should occur; or
A string representing a Crontab pattern. This may get pretty advanced, like
hour='*/3'
(for every three hours) orhour='0,8-17/2'
(at midnight, and every two hours during office hours).
- day_of_week¶
A (list of) integers from 0-6, where Sunday = 0 and Saturday = 6, that represent the days of a week that execution should occur.
A string representing a Crontab pattern. This may get pretty advanced, like
day_of_week='mon-fri'
(for weekdays only). (Beware thatday_of_week='*/2'
does not literally mean ‘every two days’, but ‘every day that is divisible by two’!)
- day_of_month¶
A (list of) integers from 1-31 that represents the days of the month that execution should occur.
A string representing a Crontab pattern. This may get pretty advanced, such as
day_of_month='2-30/2'
(for every even numbered day) orday_of_month='1-7,15-21'
(for the first and third weeks of the month).
- month_of_year¶
A (list of) integers from 1-12 that represents the months of the year during which execution can occur.
A string representing a Crontab pattern. This may get pretty advanced, such as
month_of_year='*/3'
(for the first month of every quarter) ormonth_of_year='2-12/2'
(for every even numbered month).
- app¶
The Celery app instance.
It’s important to realize that any day on which execution should occur must be represented by entries in all three of the day and month attributes. For example, if
day_of_week
is 0 andday_of_month
is every seventh day, only months that begin on Sunday and are also in themonth_of_year
attribute will have execution events. Or,day_of_week
is 1 andday_of_month
is ‘1-7,15-21’ means every first and third Monday of every month present inmonth_of_year
.Constructors¶
-
crontab(minute: int | str | Iterable[int] =
'*'
, ...)[source] Initialize self. See help(type(self)) for accurate signature.
Public members¶
- property app : Celery
- classmethod from_string(crontab: str) crontab [source]
Create a Crontab from a cron expression string. For example
crontab.from_string('* * * * *')
.
- is_due(last_run_at: datetime) tuple[bool, datetime] [source]
Return tuple of
(is_due, next_time_to_run)
.
- maybe_make_aware(dt: datetime, ...) datetime
- remaining_estimate(...) timedelta [source]
Estimate of next run time.
- property utc_enabled : bool
Helper methods¶
- __reduce__() tuple[type, tuple[int | str | Iterable[int], int | str | Iterable[int], int | str | Iterable[int], int | str | Iterable[int], int | str | Iterable[int]], Any] [source]
Helper for pickle.
Comparison operators¶
String representation¶