Skip to main content

Run commands with a cron expression or loop mode

Project description

cronrun

日本語版 README Specification

cronrun is a CLI tool to run commands in either:

  • cron mode: cronrun "<CRONTAB_LINE>"
  • loop mode: cronrun --loop <command> [args...]
  • optional logging: add --log

It is a foreground process (not a daemon): schedules exist only while cronrun is running.

Install

pipx install cronrun

Quick Start

# cron mode: run every minute
cronrun "* * * * * echo hello"

# loop mode: run immediately after each completion
cronrun --loop /bin/echo hello

# loop mode with shell expression
cronrun --loop "date; sleep 2"

# with logs
cronrun --log "* * * * * echo hello"

Usage

cron mode

cronrun [--log] "<minute> <hour> <day-of-month> <month> <day-of-week> <command> [args...]"
  • The first 5 fields are parsed as the cron expression
  • The rest is treated as one command string and executed through shell (/bin/sh -c equivalent)
  • No overlap protection: if the next schedule arrives while a previous run is still running, a new run starts

Examples:

cronrun "*/5 * * * * php worker.php"
cronrun "0 2 * * * ./backup.sh"
cronrun "* * * * * flock -n /tmp/worker.lock php worker.php"

loop mode

cronrun [--log] --loop <command> [args...]
  • Repeats: run -> wait -> run again
  • Restarts immediately after each completion
  • Commands run through shell
  • Single argument is treated as the shell command string directly
  • Multiple arguments are composed into one command string, then executed

Examples:

cronrun --loop "date; sleep 2"
cronrun --loop echo hello
cronrun --loop flock -n /tmp/worker.lock php worker.php

Signal Handling

On SIGINT (Ctrl+C) or SIGTERM:

  • Stop starting new runs
  • Wait for currently running child processes
  • Exit after they finish

If no child process is running, it exits immediately.

Logging (--log)

Enable runtime logs with --log.

  • Logs are written to stderr
  • Timestamps use local timezone (ISO 8601)
  • cron mode logs:
    • cron.next (next scheduled run time)
    • run.start
    • run.done (duration and exit code)
  • loop mode logs:
    • run.start
    • run.done (duration and exit code)
  • On SIGINT / SIGTERM:
    • signal.received
    • shutdown.waiting (only when running jobs exist)
    • shutdown.complete

Timezone and DST

  • Schedule evaluation uses OS local timezone
  • No tool-specific timezone option is provided
  • DST transitions follow local time behavior

Exit Codes

  • 0: normal exit (--help, --version, or graceful stop by signal)
  • 1: input or validation errors (invalid cron, missing command, invalid arguments)

Notes

  • Error messages are emitted to stderr as error: <message>
  • cronrun does not manage crontab files, persistent daemonization, job history, or logging

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

cronrun-1.0.2.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

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

cronrun-1.0.2-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file cronrun-1.0.2.tar.gz.

File metadata

  • Download URL: cronrun-1.0.2.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cronrun-1.0.2.tar.gz
Algorithm Hash digest
SHA256 036fe46b425095217e392f36af492e31538c5af4e8ad6b17900f4e4f475088fd
MD5 957c06bbe5b500c4a2eaffd5b402483b
BLAKE2b-256 c522f17cb8628c398e892d11968ddfeba06c6fcb1034f23e09ed94f632b74755

See more details on using hashes here.

Provenance

The following attestation bundles were made for cronrun-1.0.2.tar.gz:

Publisher: release.yml on tanakamasayuki/cronrun

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cronrun-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: cronrun-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cronrun-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ebc070532636efad3a512fa661e6eef537b0a4e5b33ae7f68b3b33fc07b1df5a
MD5 04811e0d1e0eefa8c97d9ebaa8b80680
BLAKE2b-256 5c3e332d44768ab2c83ecb5e3329eb936297ed9738a16d0b41a42f4c71cd4095

See more details on using hashes here.

Provenance

The following attestation bundles were made for cronrun-1.0.2-py3-none-any.whl:

Publisher: release.yml on tanakamasayuki/cronrun

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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