Run commands with a cron expression or loop mode
Project description
cronrun
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 -cequivalent) - 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)
cronmode logs:cron.next(next scheduled run time)run.startrun.done(duration and exit code)
loopmode logs:run.startrun.done(duration and exit code)
- On
SIGINT/SIGTERM:signal.receivedshutdown.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)
Time Acceleration Test (faketime)
Use faketime without --exclude-monotonic.
# cron mode (x10 accelerated wall-clock)
faketime -f "+0 x10" uv run --no-sync cronrun --log "* * * * * date"
# loop mode
faketime -f "+0 x10" uv run --no-sync cronrun --log --loop "date; sleep 2"
Notes:
uv run --no-syncavoids reinstall noise during repeated local tests.- If you use
--exclude-monotonic, waits may follow real-time and the behavior can differ.
Notes
- Error messages are emitted to
stderraserror: <message> cronrundoes 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cronrun-1.0.3.tar.gz.
File metadata
- Download URL: cronrun-1.0.3.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68b3bdcb7c2505564d7a996813763fd4345d39e1d47fa857dff1ebc6f541d136
|
|
| MD5 |
1eb1904339942f38f694ab6d2cf1dcf1
|
|
| BLAKE2b-256 |
dc1fe9dc725963158e277475779b53c7ba2084f9610c191f307536600680a4a5
|
Provenance
The following attestation bundles were made for cronrun-1.0.3.tar.gz:
Publisher:
release.yml on tanakamasayuki/cronrun
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cronrun-1.0.3.tar.gz -
Subject digest:
68b3bdcb7c2505564d7a996813763fd4345d39e1d47fa857dff1ebc6f541d136 - Sigstore transparency entry: 1063585620
- Sigstore integration time:
-
Permalink:
tanakamasayuki/cronrun@f4a99ae184009324daccf8c1f1d540fd300ade72 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tanakamasayuki
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f4a99ae184009324daccf8c1f1d540fd300ade72 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file cronrun-1.0.3-py3-none-any.whl.
File metadata
- Download URL: cronrun-1.0.3-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf0141ece514c77ae790ae6cc680eaa7c9ef609f28c3581b3428158b2b5c5253
|
|
| MD5 |
9b47ddd14294ac70a6c0502eeced1b6e
|
|
| BLAKE2b-256 |
b887ad0cd06c3d68044c764037630df044f0ccca7423d5be958cbd85bbb204d0
|
Provenance
The following attestation bundles were made for cronrun-1.0.3-py3-none-any.whl:
Publisher:
release.yml on tanakamasayuki/cronrun
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cronrun-1.0.3-py3-none-any.whl -
Subject digest:
cf0141ece514c77ae790ae6cc680eaa7c9ef609f28c3581b3428158b2b5c5253 - Sigstore transparency entry: 1063585679
- Sigstore integration time:
-
Permalink:
tanakamasayuki/cronrun@f4a99ae184009324daccf8c1f1d540fd300ade72 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tanakamasayuki
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f4a99ae184009324daccf8c1f1d540fd300ade72 -
Trigger Event:
workflow_dispatch
-
Statement type: