{"id":15024404,"url":"https://github.com/paulonteri/django-serverless-cron","last_synced_at":"2025-04-12T06:30:49.641Z","repository":{"id":40311449,"uuid":"452564842","full_name":"paulonteri/django-serverless-cron","owner":"paulonteri","description":"django-serverless-cron 🦡 A Django library with a simpler approach running cron jobs in a serverless environment through HTTP requests. This allows you to run any task without having to manage always-on infrastructure. https://pypi.org/project/django-serverless-cron","archived":false,"fork":false,"pushed_at":"2022-11-07T22:46:04.000Z","size":64,"stargazers_count":55,"open_issues_count":0,"forks_count":15,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T18:58:07.798Z","etag":null,"topics":["async","cron","cronjob","django","python","serverless"],"latest_commit_sha":null,"homepage":"https://django-serverless-cron.readthedocs.io/en/latest","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/paulonteri.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-27T06:25:11.000Z","updated_at":"2024-09-21T09:15:08.000Z","dependencies_parsed_at":"2023-01-22T11:45:41.329Z","dependency_job_id":null,"html_url":"https://github.com/paulonteri/django-serverless-cron","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulonteri%2Fdjango-serverless-cron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulonteri%2Fdjango-serverless-cron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulonteri%2Fdjango-serverless-cron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulonteri%2Fdjango-serverless-cron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paulonteri","download_url":"https://codeload.github.com/paulonteri/django-serverless-cron/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248529235,"owners_count":21119467,"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":["async","cron","cronjob","django","python","serverless"],"created_at":"2024-09-24T20:00:18.978Z","updated_at":"2025-04-12T06:30:49.108Z","avatar_url":"https://github.com/paulonteri.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"=============================\ndjango-serverless-cron 🦡\n=============================\n\n.. image:: https://badge.fury.io/py/django-serverless-cron.svg\n    :target: https://badge.fury.io/py/django-serverless-cron\n\n.. image:: https://github.com/paulonteri/django-serverless-cron/actions/workflows/tests.yml/badge.svg\n    :target: https://github.com/paulonteri/django-serverless-cron/actions/workflows/tests.yml\n\n.. image:: https://codecov.io/gh/paulonteri/django-serverless-cron/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/paulonteri/django-serverless-cron\n\n.. image:: https://readthedocs.org/projects/django-serverless-cron/badge/?version=latest\n     :target: http://django-serverless-cron.readthedocs.io/?badge=latest\n\n\ndjango-serverless-cron is a Django app with a simpler approach running cron jobs.\nThis is done through exposing a HTTP endpoint to invoke the jobs that allows you to run any task without having to manage always-on infrastructure.\n\nThere is also an option to run jobs via management commands and the Django admin.\n\nWhy?\n----\n\nThis is essentially a replacement/supplement for a traditional OS 'cron' or 'job scheduler' system:\n\n- Serverless cron jobs no-longer a pain. Note that if you have alternatives like django-crontab or celery working well for you, good for you! You probably don't need this. However, it's okay to be curious.\n- Schedule jobs to run at a frequency that is less than 1 min. (crontab is limited to 1 min)\n- The machine running crontab is no longer a single point of failure.\n- The problem with the above systems is that they are often configured at the operating system level, which means their configuration is probably not easily 'portable' and 'debug-able' (if you are developing on Windows, the scheduler works differently from Linux or Unix). Also can not easily be integrated into a development environment.\n- Manually triggered cron jobs. Eg: via the Django Admin.\n- Alternative to cron services that aren't always available on free (and sometimes paid) web hosting services.\n- Easier access to cron job execution logs and monitoring execution failures.\n- No need to learn crontab. Think of it as a friendlier alternative to traditional cron jobs. Simple cron job creation. No need for cron syntax, no guessing on job frequency. Easy controls.\n- Designed around services like `Google Cloud Scheduler` and `Amazon EventBridge`.\n\nDocumentation\n-------------\n\nDocumentation is graciously hosted at https://django-serverless-cron.readthedocs.io.\n\nContributions\n-------------\n\nFeel free to make pull requests and submit issues/requests.\nFind more detailed instructions under the `contributing` section.\n\nAlternatively, you can leave a star on the repo to show your support. 🙂\n\nQuickstart\n----------\n\nInstallation\n^^^^^^^^^^^^\n\nInstall Django Serverless Cron::\n\n    pip install django-serverless-cron\n\n\nSettings\n^^^^^^^^\n\nAdd it to your `INSTALLED_APPS`:\n\n.. code-block:: python\n\n    INSTALLED_APPS = (\n        # ...\n        'django_serverless_cron'\n        # ...\n    )\n\nAdd jobs to your settings file:\n\n.. code-block:: python\n\n    SERVERLESS_CRONJOBS = [\n        # (\n        #   '1_hours',                       # frequency (seconds, minutes, hours, days, weeks) -\u003e in this case, every one hour\n        #   'mail.jobs.send_mail_function',  # path to task/function functions -\u003e in this case, send_mail_function()\n        #   {'kwarg1': 'foo'}                # kwargs passed to the function\n        # ),\n        (\n            '1_days',\n            'your_app.services.your_job_function',\n            {'kwarg1': 'foo', 'kwarg2': 'bar', \"is_bulk\": True}\n        ),\n        (\n            '1_hours',\n            'mail.jobs.send_mail_function',\n            {}                               # job without kwargs\n        ),\n    ]\n\n\nURL patterns\n^^^^^^^^^^^^\nAdd the jobs to your URL patterns:\n\n.. code-block:: python\n\n    from django.urls import path, re_path, include #add re_path and include\n    from django_serverless_cron import urls as django_serverless_cron_urls\n\n\n    urlpatterns = [\n        # ...\n        re_path(r'^', include(django_serverless_cron_urls)),\n        #...\n    ]\n\nMigrate\n^^^^^^^\n\n.. code-block:: bash\n\n    python manage.py migrate\n\nRunning Jobs\n------------\n\nIn Development\n^^^^^^^^^^^^^^\n\nRunning Jobs through HTTP requests\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\nCall the `/run` path to run all jobs:\n\nExample:\n\n.. code-block:: bash\n\n    curl http://localhost:8000/run\n\nor\n\n.. code-block:: python\n\n    import requests\n\n    x = requests.get('http://localhost:8000/run')\n\n\nRunning Jobs through the management command\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\n\nThis will run the jobs every 30 seconds:\n\n.. code-block:: bash\n\n    python manage.py serverless_cron_run\n\nYou can alternatively add the `--single_run='True'` option to run the jobs just once.\n\nIn Production\n^^^^^^^^^^^^^\n\nSimilar to in development, we can call the `/run` path via fully managed services which are usually ridiculously cheap. Examples:\n\n- https://cloud.google.com/scheduler -\u003e Great feature set, easy to use, reasonable free tier \u0026 very cheap.\n- https://aws.amazon.com/eventbridge\n- https://azure.microsoft.com/en-gb/services/logic-apps formerly https://docs.microsoft.com/en-us/azure/scheduler/scheduler-intro\n- https://cron-job.org/en/ -\u003e Absolutely free and open-source: https://github.com/pschlan/cron-job.org\n- https://www.easycron.com\n- https://cronhub.io\n- https://cronless.com -\u003e Has 30 Second Cron Jobs\n- https://github.com/features/actions; https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onschedule -\u003e eg making a HTTP request using `curl` in a step\n- https://www.cronjob.de\n- https://zeplo.io\n- https://catalyst.zoho.com/help/cron.html\n- https://www.cronjobservices.com\n\nRelated media\n-------------\n\nFor more learning check out:\n\n- https://dev.to/googlecloud/when-you-re-not-around-trigger-cloud-run-on-a-schedule-53p4 | https://youtu.be/XIwbIimM49Y\n- https://aws.amazon.com/blogs/compute/using-api-destinations-with-amazon-eventbridge/\n- https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/RunLambdaSchedule.html\n- https://www.ibm.com/cloud/blog/how-to-schedule-rest-api-calls-on-ibm-cloud\n- https://vercel.com/docs/concepts/solutions/cron-jobs\n- cron-like recurring task scheduler design https://stackoverflow.com/a/3980935/10904662\n- https://www.dailyhostnews.com/google-cloud-launches-fully-managed-cron-job-scheduler-for-enterprises\n- Cloud Scheduler from Fireship https://www.youtube.com/watch?v=WUPEUjvSBW8\n\nCredits\n-------\n\nTools used in rendering this package:\n\n*  Cookiecutter_\n*  `cookiecutter-djangopackage`_\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulonteri%2Fdjango-serverless-cron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulonteri%2Fdjango-serverless-cron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulonteri%2Fdjango-serverless-cron/lists"}