Skip to content

arq-cron

Requires arq 0.26+, Python 3.11+. See the compatibility matrix for the full pin string.

Terminal window
pip install z4j-arqcron

arq's cron jobs are declared in WorkerSettings.cron_jobs:

from arq.cron import cron
async def weekly_roundup(ctx):
...
class WorkerSettings:
cron_jobs = [cron(weekly_roundup, weekday="mon", hour=9)]

This is code. To add a cron job, you deploy new code. You construct ArqCronAdapter(cron_jobs=WorkerSettings.cron_jobs, project_id=...) with the same iterable the worker uses, and z4j lists that copy; it cannot add new ones at runtime.

  • The job's name (falling back to the coroutine's __name__), used as both the schedule name and the task name.
  • A five-field cron expression rebuilt from the job's minute, hour, day, month and weekday constraints. A second constraint is not shown, the timezone always reads UTC, and every job reads as enabled.
  • Changes to cron_jobs require a worker restart; z4j re-syncs on next connect.
  • arq doesn't expose a runtime pause. If you need pause, wrap your function body in a feature-flag check.

If you move scheduling to z4j-scheduler, z4j-scheduler import --from arq --arq-settings pkg.worker:WorkerSettings --project <slug> reads cron_jobs from the same class the worker runs, and z4j-scheduler export --to arq renders the entries back as a Python module you review and apply.

arq.