A robust CLI tool for managing cron tasks with automatic job execution and log management.
- Simple CLI interface for creating, listing, and stopping cron jobs
- Automatic job execution via a background daemon
- Log rotation that maintains separate stdout and stderr logs
- Automatic startup on system reboot
- Stable job IDs that persist after job deletion
-
Clone the repository:
git clone https://github.com/rrainn/cronr.git cd cronr -
Build and install the binary:
cargo install --path . -
Set up the daemon to run on startup:
On Linux (with systemd):
sudo ./scripts/install_linux.shOn macOS:
./scripts/install_macos.sh
Download the appropriate binary for your platform from the Releases page.
cronr create "your_command_here" "cron_schedule"
Example:
cronr create "curl -v https://ip.rrainn.space" "0 5 4 * * *"
This will create a job that runs curl -v https://ip.rrainn.space at 4:05 AM every day.
cronr ls
This shows all cron jobs, including:
- ID number
- Cron schedule
- Command being run
cronr stop ID
Example:
cronr stop 2
This will permanently delete the cron job with ID 2.
cronr version
Or use the shorthand:
cronr -v
cronr status
This shows:
- cronr version
- number of active jobs
- whether the daemon is running
Cronr stores all its data in the ~/.cronr directory:
jobs.json: Contains all job configurations. Mutations reload the latest state under a cross-process lock and publish through exclusively created temporary files, preserving concurrent job completions and CLI changes.jobs.lock: Stable persistence lock file; keep it in place while cronr is running.logs/: Directory containing all job output logs{job_id}.out.log: Standard output from the job{job_id}.err.log: Standard error from the job- Log files rotate when they reach 5MB in size
Existing legacy job maps remain readable and are migrated to the metadata format on the next successful mutation. Invalid JSON is reported with its original parse diagnostic and is never replaced with an empty configuration. The scheduler's graceful shutdown and reload-failure paths stop executors. The owning process cleans up its PID marker after the internal scheduler exits.
When upgrading, stop the old daemon before installing and restarting the new binary: older versions do not participate in the persistence lock. To roll back, stop cronr and reinstall the previous binary; the JSON schema is unchanged. Back up jobs.json before manually repairing a corrupt file.
- Rust and Cargo (1.70.0 or later)
- For Linux: systemd development libraries
- For testing: Rust test framework
cargo build
cargo test
This will run both unit tests and integration tests.
The repository includes CI workflows for GitHub Actions that automatically build and test the code on each commit.
MIT