{"id":13816517,"url":"https://github.com/kraiz/django-crontab","last_synced_at":"2025-12-18T03:05:08.113Z","repository":{"id":48971915,"uuid":"2069170","full_name":"kraiz/django-crontab","owner":"kraiz","description":"dead simple crontab powered job scheduling for django.","archived":false,"fork":false,"pushed_at":"2022-10-04T15:02:40.000Z","size":108,"stargazers_count":847,"open_issues_count":41,"forks_count":114,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-04-25T00:34:16.545Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kraiz.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG","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":"2011-07-18T22:21:21.000Z","updated_at":"2025-04-19T07:29:35.000Z","dependencies_parsed_at":"2022-08-30T07:50:57.260Z","dependency_job_id":null,"html_url":"https://github.com/kraiz/django-crontab","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kraiz%2Fdjango-crontab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kraiz%2Fdjango-crontab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kraiz%2Fdjango-crontab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kraiz%2Fdjango-crontab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kraiz","download_url":"https://codeload.github.com/kraiz/django-crontab/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254367697,"owners_count":22059556,"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":[],"created_at":"2024-08-04T05:00:44.393Z","updated_at":"2025-12-18T03:05:08.025Z","avatar_url":"https://github.com/kraiz.png","language":"Python","readme":".. image:: https://img.shields.io/travis/kraiz/django-crontab/master.svg\n    :target: https://travis-ci.org/kraiz/django-crontab\n.. image:: https://img.shields.io/coveralls/kraiz/django-crontab/master.svg\n    :target: https://coveralls.io/r/kraiz/django-crontab\n.. image:: https://img.shields.io/pypi/v/django-crontab.svg\n    :target: https://pypi.python.org/pypi/django-crontab\n.. image:: https://img.shields.io/pypi/pyversions/django-crontab.svg\n    :target: https://pypi.python.org/pypi/django-crontab\n.. image:: https://img.shields.io/pypi/l/django-crontab.svg\n    :target: https://pypi.python.org/pypi/django-crontab\n\nabout\n=====\n\ndead simple crontab powered job scheduling for django (1.8-2.0).\n\nsetup\n=====\ninstall via pip:\n\n.. code:: bash\n\n    pip install django-crontab\n\nadd it to installed apps in django settings.py:\n\n.. code:: python\n\n    INSTALLED_APPS = (\n        'django_crontab',\n        ...\n    )\n\nnow create a new method that should be executed by cron every 5 minutes, f.e. in `myapp/cron.py`:\n\n.. code:: python\n\n    def my_scheduled_job():\n      pass\n\nnow add this to your settings.py:\n\n.. code:: python\n\n    CRONJOBS = [\n        ('*/5 * * * *', 'myapp.cron.my_scheduled_job')\n    ]\n\nyou can also define positional and keyword arguments which let you call django management commands:\n\n.. code:: python\n\n    CRONJOBS = [\n        ('*/5 * * * *', 'myapp.cron.other_scheduled_job', ['arg1', 'arg2'], {'verbose': 0}),\n        ('0   4 * * *', 'django.core.management.call_command', ['clearsessions']),\n    ]\n\nfinally, run this command to add all defined jobs from `CRONJOBS` to crontab (of the user which you are running this command with):\n\n.. code:: bash\n\n    python manage.py crontab add\n\nshow current active jobs of this project:\n\n.. code:: bash\n\n    python manage.py crontab show\n\nremoving all defined jobs is straightforward:\n\n.. code:: bash\n\n    python manage.py crontab remove\n\nconfig\n======\nthere are a bunch of setting vars to customize behavior. each of them comes with default values that should properly fit. if not, feel free to overwrite.\n\nCRONJOBS\n  - list of jobs, each defined as a tuple:\n\n    - format 1:\n\n      1. required: cron timing in usual format (see `Wikipedia \u003chttp://en.wikipedia.org/wiki/Cron#Format\u003e`_ and `crontab.guru \u003chttps://crontab.guru/examples.html\u003e`_ for more examples)\n      2. required: the python module path to the method\n      3. optional: a job-specific suffix (f.e. to redirect out/err to a file, default: '')\n\n    - format 2:\n\n      1. required: cron timing\n      2. required: the python module path to the method\n      3. optional: list of positional arguments for the method (default: [])\n      4. optional: dict of keyword arguments for the method (default: {})\n      5. optional: a job specific suffix (f.e. to redirect out/err to a file, default: '')\n\n  - NOTE: Run \"python manage.py crontab add\" each time you change CRONJOBS in any way!\n  - default: []\n  - example:\n\n    .. code:: python\n\n        CRONJOBS = [\n            ('*/5 * * * *', 'myapp.cron.my_scheduled_job'),\n\n            # format 1\n            ('0   0 1 * *', 'myapp.cron.my_scheduled_job', '\u003e\u003e /tmp/scheduled_job.log'),\n\n            # format 2\n            ('0   0 1 * *', 'myapp.cron.other_scheduled_job', ['myapp']),\n            ('0   0 * * 0', 'django.core.management.call_command', ['dumpdata', 'auth'], {'indent': 4}, '\u003e /home/john/backups/last_sunday_auth_backup.json'),\n        ]\n\nCRONTAB_LOCK_JOBS\n  - prevent starting a job if an old instance of the same job is still running\n  - default: False\n  - since 0.5.0\n\nCRONTAB_EXECUTABLE\n  - path to the crontab executable of your os\n  - default: '/usr/bin/crontab'\n\nCRONTAB_DJANGO_PROJECT_NAME\n  - the name of your django project, used to build path path to manage.py and to mark the jobs in crontab via comment for later removing\n  - default is read from DJANGO_SETTINGS_MODULE environment variable\n\nCRONTAB_DJANGO_MANAGE_PATH\n  - path to manage.py file (including the manage.py itself, i.e. '/home/john/web/manage.py')\n  - default is build using DJANGO_PROJECT_NAME\n\nCRONTAB_DJANGO_SETTINGS_MODULE\n  - dotted python path to the settings module to run the command with\n  - default is the common one from the environment variable and will not be overwritten\n  - since 0.6.0\n\nCRONTAB_PYTHON_EXECUTABLE\n  - path to the python interpreter executable used to run the scheduled job\n  - default uses the interpreter executable used to `add` the jobs (via 'python manage.py crontab add')\n\nCRONTAB_COMMAND_PREFIX\n  - something you want to do or declare, before each job gets executed. A good place for environment variables.\n  - default: '' (empty string)\n  - example: 'STAGE=production'\n\nCRONTAB_COMMAND_SUFFIX\n  - something you want to do after each job was executed.\n  - default: '' (empty string)\n  - example: '2\u003e\u00261'\n\nCRONTAB_COMMENT\n  - used for marking the added contab-lines for removing, default value includes project name to distinguish multiple projects on the same host and user\n  - default: 'django-crontabs for ' + CRONTAB_DJANGO_PROJECT_NAME\n\ncontributors\n============\narski cinghiale meric426 justdoit0823 chamaken\n\nfaq\n===\n* **I'm using this old django version (\u003c1.8) and can't install this package. What should i do?**\n  - Yeah, update django of course (!) or - as you seem to be familiar with old, unsupported versions, install the old version of this package too (it support django 1.3-1.7)::\n\n    pip install django-crontab==0.6.0\n\n* **Will it work with windows?**\n  - No.\n* **Will it work within a docker?**\n  - Not immediately, you need to start the cron service.\n* **Problems with `pyenv`?**\n  - You maybe need to setup the PATH variable within crontab. Have a look at `#60 \u003c/../../issues/60\u003e`_\n* **I'm getting \"bad command\"/\"errors in cronfile\" while installing via \"crontab add\". What's wrong?**\n  - Maybe it's your cron time format, it can have 5 or 6 fields. Check that your system supports 6 or just define 5 in `CRONJOBS`. (see #23)\n* **Why does the LOGGING not work when started via cronjob?**\n  - That's maybe something about the current working dir. Please set your FileHandler's file path absolute and try again. (see `#31 \u003c/../../issues/31\u003e`_)\n\nlicense\n=======\nMIT-License, see LICENSE file.\n","funding_links":[],"categories":["Python","\u003ca name=\"Python\"\u003e\u003c/a\u003ePython"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkraiz%2Fdjango-crontab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkraiz%2Fdjango-crontab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkraiz%2Fdjango-crontab/lists"}