Skip to main content

banner

A simple Python library providing cron functionality via the use of a single decorator.

Installation

The latest version of pycron may be installed via pip as follows:

pip install python-cron

Usage

The pycron module provides a @cron decorator that may be used to mark functions declared async as cron jobs. The decorator takes a croniter-style cron string as input to determine when the function should be executed. For example, the following test function would be automatically executed every 5 seconds:

from datetime import datetime
import pycron

@pycron.cron("* * * * * */5")
async def test(timestamp: datetime):
    print(f"test cron job running at {timestamp}")

if __name__ == '__main__':
    pycron.start()

All functions declared with the @cron decorator should take a single positional argument that will contain the current timestamp when the function is automatically invoked. Also note the usage of the pycron.start() method. This function signals that automated job scheduling and execution should begin and it should be invoked after all jobs have been declared.

For more information on the format of the cron strings that should be provided to the @cron decorator, please see the croniter documentation on PyPI.

Release files for python-cron 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-cron 1.0.1
File Size Uploaded
python-cron-1.0.1.tar.gz 4.0 kB Details

Release files / python-cron-1.0.1.tar.gz

Download URL python-cron-1.0.1.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3be6febfb0e13af9fe70ad3f099e82b10778c544f160bbbfa6ab88b0ff7d7a3c
BLAKE2b-256 checksum
How to use checksums
ca6df4069d6bf7a1decf5c00c21ff5cdb095baad693f3849fe066a7f2a308183
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page