Skip to main content

A multi-platform cron-like job runner in Python

Project description

Pycroner

Pycroner

Pycroner is a lightweight cron style job runner implemented in Python. Jobs are configured via a YAML file and executed by the runner once their cron schedule matches the current time.

Features

  • Parses standard five field cron expressions (minute, hour, day, month, weekday) using a small built in parser.
  • Jobs can optionally be fanned out into multiple processes. Fanout may be an integer (repeat the job N times) or a list of argument strings that will be appended to the base command.
  • Configuration lives in pycroner.yml by default. The exact format is described in pycroner/spec.md.

Installation

From PyPI:

pip install pycroner

Usage

From code

  1. Create a pycroner.yml file describing your jobs. A simple example is shown below.
  2. Run the job runner from a Python script:
from pycroner.runner import run

run("pycroner.yml")

The runner checks schedules every minute and spawns each job as a subprocess when its cron expression matches the current time.

From CLI

You can also invoke the runner directly from the command line using the pycroner command. By default it looks for pycroner.yml in the current directory:

pycroner

Specify an alternative working directory with --at or a specific configuration file with --config:

pycroner --at /path/to/project
pycroner --config custom.yml

Example Configuration

jobs:
  - id: "index_articles"
    schedule: "*/15 * * * *"
    command: "python index.py"
    fanout: 4

  - id: "daily_etl"
    schedule: "0 2 * * *"
    command: "python etl.py"
    fanout:
      - "--source=internal --mode=full"
      - "--source=external --mode=delta"

  - id: "ping"
    schedule: "* * * * *"
    command: "python ping.py"

Jobs run independently, and any output or error handling is left to your commands. For full details see pycroner/spec.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycroner-0.1.1.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycroner-0.1.1-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file pycroner-0.1.1.tar.gz.

File metadata

  • Download URL: pycroner-0.1.1.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pycroner-0.1.1.tar.gz
Algorithm Hash digest
SHA256 74fe7820a825e3a0c709bbfa9d6a97eccc19cbd6f3444af80ee639d7ca38fed4
MD5 91b3c9d02997da1824529764789703e8
BLAKE2b-256 8f698b5121b776f24751f30f8f7057b4ee6747fef6da9664f7a8a5bcf023909f

See more details on using hashes here.

File details

Details for the file pycroner-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pycroner-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pycroner-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5676ecbcc85de6da098703234a7102073100b6d120f5cacbc70313541038f42a
MD5 c3f83b9d8b5c5c26e2ca4167e0bd82bd
BLAKE2b-256 3f65ded740c9cbaf3879512485727e4c0c1cc3eecb9c5c77cf6755172a7e1977

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page