{"id":15024941,"url":"https://github.com/frostming/flask-crontab","last_synced_at":"2025-05-07T09:44:41.471Z","repository":{"id":36469744,"uuid":"226436916","full_name":"frostming/flask-crontab","owner":"frostming","description":"Simple Flask scheduled tasks without extra daemons","archived":false,"fork":false,"pushed_at":"2021-11-10T19:28:52.000Z","size":26,"stargazers_count":101,"open_issues_count":5,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-26T12:48:39.569Z","etag":null,"topics":["background-jobs","crontab","extension","flask"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/frostming.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-07T01:13:16.000Z","updated_at":"2024-11-28T06:37:13.000Z","dependencies_parsed_at":"2022-09-03T00:22:07.330Z","dependency_job_id":null,"html_url":"https://github.com/frostming/flask-crontab","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frostming%2Fflask-crontab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frostming%2Fflask-crontab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frostming%2Fflask-crontab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frostming%2Fflask-crontab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frostming","download_url":"https://codeload.github.com/frostming/flask-crontab/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252853372,"owners_count":21814515,"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":["background-jobs","crontab","extension","flask"],"created_at":"2024-09-24T20:01:15.074Z","updated_at":"2025-05-07T09:44:41.451Z","avatar_url":"https://github.com/frostming.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flask-crontab\n\n\u003e Simple Flask scheduled tasks without extra daemons\n\n[![PyPI](https://img.shields.io/pypi/v/flask-crontab)](https://pypi.org/project/flask-crontab) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/flask-crontab)](https://pypi.org/project/flask-crontab) [![Github Action](https://github.com/frostming/flask-crontab/workflows/Continuous%20Integration/badge.svg)](https://github.com/frostming/flask-crontab/actions?query=workflow%3A%22Continuous+Integration%22) ![Supported Platforms](https://img.shields.io/badge/platform-Linux%20%7C%20macOS-lightgrey)\n\nThis project is strongly inspired by [django-crontab](https://github.com/kraiz/django-crontab), and only works on Python 3.5+.\nDue to the coming EOL of Python 2 on 2020/01/01, there is no plan for Python 2 support.\n\n## Quick Start\n\nInstall via `pip`:\n\n```bash\n$ pip install flask-crontab\n```\n\nInstantiate the extension in your `app.py` after the creation of Flask app:\n\n```python\nfrom flask import Flask\nfrom flask_crontab import Crontab\n\napp = Flask(__name__)\ncrontab = Crontab(app)\n```\n\nIf you are using App Factory pattern, you can also register the extension later:\n\n```python\ncrontab = Crontab()\n\ndef create_app():\n    ...\n    crontab.init_app(app)\n```\n\nNow create a scheduled job:\n\n```python\n@crontab.job(minute=\"0\", hour=\"6\")\ndef my_scheduled_job():\n    do_something()\n```\n\nAn app context is automatically activated for every job run, so that you can access objects that are attached to app context.\nThen add the job to crontab:\n\n```bash\n$ flask crontab add\n```\n\nThat's it! If you type in `crontab -l` in your shell, you can see some new lines created by `flask-crontab`.\n\nShow jobs managed by current app:\n\n```bash\n$ flask crontab show\n```\n\nPurge all jobs managed by current app:\n\n```bash\n$ flask crontab remove\n```\n\nRun a specific job given by hash:\n\n```bash\n$ flask crontab run \u003cjob_hash\u003e\n```\n\nSee supported options via `--help` for every commands.\n\n## Decorator API\n\n```python\ndef job(\n    minute: str = \"*\",\n    hour: str = \"*\",\n    day: str = \"*\",\n    month: str = \"*\",\n    day_of_week: str = \"*\",\n    args: Tuple[Any, ...] = (),\n    kwargs: Optional[Dict[str, Any]] = None,\n) -\u003e Callable:\n```\n\nThe decorator accepts five arguments `minute`, `hour`, `day`, `month`, `day_of_month`, which are the same as crontab 5-parts time format. Any part that is not given defaults to `*`.\nBesides, `job` decorator accepts `args` and `kwargs` which will be passed to the decorated function as positional arguments and keywords arguments, respectively.\n\n## Configuration\n\n| Config item        | Description                    | Default value      |\n| ------------------ | ------------------------------ | ------------------ |\n| CRONTAB_EXECUTABLE | The absolute path of `crontab` | `/usr/bin/crontab` |\n| CRONTAB_LOCK_JOBS  | Whether lock jobs when running | `False`            |\n\n## License\n\nThis project is publised under [MIT](LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrostming%2Fflask-crontab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrostming%2Fflask-crontab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrostming%2Fflask-crontab/lists"}