Cron for a fixed application-owned declaration. Use create to obtain a CronJob for a user-owned schedule. The module functions and CronJob methods manage dynamic schedules; Cron itself has no pause, resume, or delete methods.
For setup and usage, see Cron schedules, Dynamic schedules, and Task and cron storage.
Declare a cron function
@cron(...) creates a queued task for a same-named function in a root cron/<name>.py file. Give the function a docstring. A fixed expression uses the supplied arguments on each occurrence. Omit the expression for dynamic scheduling only; in that form, do not supply arguments or a non-UTC timezone. Do not stack @cron with @task because the decorator creates its own task. Direct calls run inline.
queue="default" and max_retries=3 use the Task validation rules.
Schedule parameters
Dynamic schedule behavior
Calls require an active managed invocation and a cron-enabled runtime. Register the same durable provider for tasks and cron. Each operation checks the active application and user; retaining aCronJob does not grant access outside that scope.
CronJob is immutable. Assign the returned snapshot, for example job = await job.pause(), or fetch it again to read updated fields. Cancelling or deleting a schedule does not cancel tasks already queued or running. Cancelled schedules cannot be updated, paused, or resumed.
CronJob.run_count counts queued occurrences; CronJob.consecutive_failures counts final failed outcomes since the last success. Reaching either configured limit cancels future scheduling.
Errors
CronRecord, CronStore, and CompiledCron are integration contracts. Application tools normally work with CronJob and the module functions.
Exports
CompiledCron
One compiler-resolved schedule with a stable application-owned identity.— means no declared default):
Parameters and example
Parameters and example
CompiledCron.task_name
Return the compiler-owned native task name targeted by the schedule.Example
Example
Cron
Schedule one discovered task using a strict five-column UTC expression.— means no declared default):
Parameters and example
Parameters and example
CronConflictError
Raised when a schedule key already owns a different definition.Example
Example
CronJob
One user-owned recurring schedule retained by a running application. Obtain this object from the owning Harnest API; its constructor includes runtime bindings. Fields (— means no declared default):
Example
Example
CronJob.update
Parameters and example
Parameters and example
CronJob.pause
Example
Example
CronJob.resume
Example
Example
CronJob.cancel
Example
Example
CronJob.delete
Example
Example
CronNotFoundError
Raised when a user-owned dynamic schedule no longer exists.Example
Example
CronRecord
Private user-owned schedule with a durable next-occurrence cursor.— means no declared default):
Parameters and example
Parameters and example
CronRuntimeError
Raised when durable cron persistence or dispatch fails safely.Example
Example
CronStore
Durable CRUD and occurrence handoff on the same provider as TaskStore. User calls always include application and user predicates. Ordered queries and pagination run in the datastore. Cron parsing and next-run calculation belong to Harnest core. Providers enforce revisions and atomic handoff.Example
Example
CronStore.start
Example
Example
CronStore.close
Example
Example
CronStore.create_cron
Parameters and example
Parameters and example
CronStore.get_cron
Parameters and example
Parameters and example
CronStore.list_crons
Parameters and example
Parameters and example
CronStore.update_cron
Parameters and example
Parameters and example
CronStore.delete_cron
Parameters and example
Parameters and example
CronStore.list_due_crons
Parameters and example
Parameters and example
CronStore.commit_cron_occurrence
Parameters and example
Parameters and example
CronStoreConflictError
A schedule definition, terminal state or expected revision conflicts.Example
Example
CronUnavailableError
Raised when dynamic schedules are used outside a cron-enabled runtime.Example
Example
cancel
Permanently stop future occurrences while retaining the job record.Parameters and example
Parameters and example
create
Schedule registered work with optional dispatch and failure limits.Parameters and example
Parameters and example
cron decorator
Declare a cron function incron/ with an implicit queued task.
Omit the schedule for dynamic scheduling only. The filename and function
name must match. Direct calls remain inline; serving registers the task.
Parameters and example
Parameters and example
delete
Delete one user-owned schedule.Parameters and example
Parameters and example
get
Return one schedule owned by the active invocation user.Parameters and example
Parameters and example
list
Return a bounded stable page of schedules for the active user.Parameters and example
Parameters and example
pause
Pause one user-owned schedule.Parameters and example
Parameters and example
resume
Resume one user-owned schedule.Parameters and example
Parameters and example
update
Update one user-owned schedule through the active runtime.Parameters and example
Parameters and example