{"id":19166965,"url":"https://github.com/voiio/dramatiq-crontab","last_synced_at":"2025-05-07T13:36:55.622Z","repository":{"id":153342499,"uuid":"627476329","full_name":"voiio/dramatiq-crontab","owner":"voiio","description":"Cron style scheduler for asynchronous Dramatiq tasks in Django.","archived":false,"fork":false,"pushed_at":"2025-05-02T09:20:45.000Z","size":644,"stargazers_count":51,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-02T10:31:04.750Z","etag":null,"topics":["apscheduler","asynchronous","cron","cronjob","crontab","dramatiq","sche"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/voiio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["amureki","codingjoe"]}},"created_at":"2023-04-13T14:44:07.000Z","updated_at":"2025-05-02T09:20:48.000Z","dependencies_parsed_at":"2023-11-11T00:25:53.398Z","dependency_job_id":"f67f59b1-e7c3-4160-9e87-bc25ff786dee","html_url":"https://github.com/voiio/dramatiq-crontab","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voiio%2Fdramatiq-crontab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voiio%2Fdramatiq-crontab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voiio%2Fdramatiq-crontab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voiio%2Fdramatiq-crontab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/voiio","download_url":"https://codeload.github.com/voiio/dramatiq-crontab/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252888061,"owners_count":21819946,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apscheduler","asynchronous","cron","cronjob","crontab","dramatiq","sche"],"created_at":"2024-11-09T09:35:08.078Z","updated_at":"2025-05-07T13:36:55.601Z","avatar_url":"https://github.com/voiio.png","language":"Python","funding_links":["https://github.com/sponsors/amureki","https://github.com/sponsors/codingjoe"],"categories":[],"sub_categories":[],"readme":"# Dramatiq Crontab\n\n![dramtiq-crontab logo: person in front of a schedule](https://raw.githubusercontent.com/voiio/dramatiq-crontab/main/dramatiq-crontab.png)\n\n**Cron style scheduler for asynchronous Dramatiq tasks in Django.**\n\n* setup recurring tasks via crontab syntax\n* lightweight helpers build on robust tools like [Dramatiq][dramatiq] and [APScheduler][apscheduler]\n* [Sentry][sentry] cron monitor support\n\n[![PyPi Version](https://img.shields.io/pypi/v/dramatiq-crontab.svg)](https://pypi.python.org/pypi/dramatiq-crontab/)\n[![Test Coverage](https://codecov.io/gh/voiio/dramatiq-crontab/branch/main/graph/badge.svg)](https://codecov.io/gh/voiio/dramatiq-crontab)\n[![GitHub License](https://img.shields.io/github/license/voiio/dramatiq-crontab)](https://raw.githubusercontent.com/voiio/dramatiq-crontab/master/LICENSE)\n\n## Setup\n\nYou need to have [Dramatiq][dramatiq] installed and setup properly.\n\n```ShellSession\npython3 -m pip install dramatiq-crontab\n# or\npython3 -m pip install dramatiq-crontab[sentry]  # with sentry cron monitor support\n```\n\nAdd `dramatiq_crontab` to your `INSTALLED_APPS` in `settings.py`:\n\n```python\n# settings.py\nINSTALLED_APPS = [\n    'dramatiq_crontab',\n    # ...\n]\n```\n\nFinally, you lauch the scheduler in a separate process:\n\n```ShellSession\npython3 manage.py crontab\n```\n\n### Setup Redis as a lock backend (optional)\n\nIf you use Redis as a broker, you can use Redis as a lock backend as well.\nThe lock backend is used to prevent multiple instances of the scheduler\nfrom running at the same time. This is important if you have multiple\ninstances of your application running.\n\n```python\n# settings.py\nDRAMATIQ_CRONTAB = {\n    \"REDIS_URL\": \"redis://localhost:6379/0\",\n}\n```\n\n## Usage\n\n```python\n# tasks.py\nimport dramatiq\nfrom dramatiq_crontab import cron\n\n\n@cron(\"*/5 * * * *\")  # every 5 minutes\n@dramatiq.actor\ndef my_task():\n    my_task.logger.info(\"Hello World\")\n```\n\n### Interval\n\nIf you want to run a task more frequently than once a minute, you can use the\n`interval` decorator.\n\n```python\n# tasks.py\nimport dramatiq\nfrom dramatiq_crontab import interval\n\n\n@interval(seconds=30)\n@dramatiq.actor\ndef my_task():\n    my_task.logger.info(\"Hello World\")\n```\n\nPlease note that the interval is relative to the time the scheduler is started.\nFor example, if you start the scheduler at 12:00:00, the first run will be at\n12:00:30. However, if you restart the scheduler at 12:00:15, the first run will\nbe at 12:00:45.\n\n### Sentry Cron Monitors\n\nIf you use [Sentry][sentry] you can add cron monitors to your tasks.\nThe monitor's slug will be the actor's name. Like `my_task` in the example above.\n\n### The crontab command\n\n```ShellSession\n$ python3 manage.py crontab --help\nusage: manage.py crontab [-h] [--no-task-loading] [--no-heartbeat] [--version] [-v {0,1,2,3}]\n                         [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color]\n                         [--force-color] [--skip-checks]\n\nRun dramatiq task scheduler for all tasks with the `cron` decorator.\n\noptions:\n  -h, --help            show this help message and exit\n  --no-task-loading     Don't load tasks from installed apps.\n  --no-heartbeat        Don't start the heartbeat actor.\n```\n\n[dramatiq]: https://dramatiq.io/\n[apscheduler]: https://apscheduler.readthedocs.io/en/stable/\n[sentry]: https://docs.sentry.io/product/crons/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoiio%2Fdramatiq-crontab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvoiio%2Fdramatiq-crontab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoiio%2Fdramatiq-crontab/lists"}