FlashCron
A lightning-fast, ultra-efficient cron daemon written in Rust
Schedule tasks at the speed of light
Features | Installation | Quick Start | Documentation | Contributing
Why FlashCron?
Traditional cron daemons get the job done, but they weren't built for speed. FlashCron is engineered from the ground up for blazing-fast performance:
| Metric | FlashCron | Traditional cron | Improvement |
|---|---|---|---|
| Scheduler Init (1000 jobs) | ~400 μs | 10-50 ms | Up to 125x faster |
| Next Run Calculation | ~500 ns | 10-100 μs | Up to 200x faster |
| Memory Usage | 2-5 MB | 10-50 MB | Up to 90% less |
| Startup Time | <10 ms | 50-200 ms | Up to 20x faster |
| CPU at Idle | <0.1% | 0.5-2% | Up to 95% less |
The Flash Philosophy
- Priority Queue Scheduling: O(log n) operations, no polling loops
- Zero-Copy Parsing: Minimal allocations in hot paths
- Precise Sleep: CPU stays idle until the exact moment needed
- Concurrent Execution: Configurable parallelism with async I/O
- Optimized Binaries: LTO, stripped symbols, maximum optimization
Features
Core Functionality
- Standard Cron Expressions: Full 5-field cron syntax support
- TOML Configuration: Human-readable, version-control friendly
- Hot Reload: Automatic config reload on file changes
- Graceful Shutdown: Waits for running jobs to complete
Job Management
- Timeout Handling: Kill runaway jobs automatically
- Retry Support: Configurable retry count and delay
- Environment Variables: Per-job environment injection
- Working Directory: Per-job working directory
- Concurrent Limits: Prevent resource exhaustion
Observability
- Structured Logging: Human-readable or JSON format
- Execution History: Track job success/failure rates
- Prometheus Metrics: Optional metrics endpoint (feature flag)
Cross-Platform
- Linux: Native support, systemd integration
- macOS: Full support including Apple Silicon
- Windows: Native Windows support
Installation
From Releases (Recommended)
Linux (x86_64)
Linux (ARM64)
macOS (Intel)
macOS (Apple Silicon)
Windows
Download flashcron-windows-x86_64.zip from releases and extract to a directory in your PATH.
From Cargo
From Source
Docker
Quick Start
1. Generate Configuration
2. Edit Configuration
[]
= "info"
= 10
[]
= "0 2 * * *" # Daily at 2 AM
= "/usr/local/bin/backup.sh"
= "Daily backup"
= 3600
= 3
[]
= "0 */6 * * *" # Every 6 hours
= "find /tmp -mtime +7 -delete"
= "Clean old temp files"
= true
3. Validate Configuration
4. Start the Daemon
CLI Reference
| Command | Description |
|---|---|
flashcron run -c config.toml |
Start the daemon |
flashcron validate -c config.toml |
Validate configuration |
flashcron list -c config.toml |
List all jobs |
flashcron schedule -c config.toml |
Show upcoming runs |
flashcron trigger <job> -c config.toml |
Trigger job manually |
flashcron init -o config.toml |
Generate default config |
Options
| Option | Description |
|---|---|
-c, --config <PATH> |
Configuration file path |
-l, --log-level <LEVEL> |
Log level (trace, debug, info, warn, error) |
--json |
Output logs in JSON format |
--foreground |
Run in foreground (don't daemonize) |
Configuration Reference
Global Settings
[]
= "info" # trace, debug, info, warn, error
= false # JSON format for log aggregators
= 10 # 0 = unlimited
= "/bin/sh" # Default shell
= true # Hot reload on config changes
= 1000 # Job execution history size
= 30 # Seconds to wait on shutdown
Job Configuration
[]
= "*/5 * * * *" # Cron expression (required)
= "echo 'Hello'" # Command to execute (required)
= "Example job" # Optional description
= true # Enable/disable job
= "/app" # Working directory
= { = "value" } # Environment variables
= 300 # Timeout in seconds (0 = none)
= "/bin/bash" # Override default shell
= 3 # Retry on failure
= 60 # Seconds between retries
= 1048576 # Max stdout/stderr capture (bytes)
= false # Run immediately on daemon start
Cron Expression Format
┌───────────── minute (0-59)
│ ┌───────────── hour (0-23)
│ │ ┌───────────── day of month (1-31)
│ │ │ ┌───────────── month (1-12)
│ │ │ │ ┌───────────── day of week (1-7, Sunday = 7)
│ │ │ │ │
* * * * *
Examples:
| Expression | Description |
|---|---|
* * * * * |
Every minute |
*/5 * * * * |
Every 5 minutes |
0 * * * * |
Every hour |
0 0 * * * |
Daily at midnight |
0 2 * * * |
Daily at 2 AM |
0 0 * * 7 |
Weekly on Sunday |
0 0 1 * * |
Monthly on the 1st |
0 9-17 * * 1-5 |
Weekdays 9 AM - 5 PM hourly |
30 4 1,15 * * |
At 4:30 on 1st and 15th |
Performance Benchmarks
Measured on AMD Ryzen 5 / Intel i7 equivalent:
| Operation | Time | Notes |
|---|---|---|
| Cron expression parsing | 1.8-4.9 μs | Depending on complexity |
| Next occurrence calculation | 400-500 ns | Sub-microsecond |
| Scheduler init (10 jobs) | ~10 μs | Instant startup |
| Scheduler init (100 jobs) | ~50 μs | Scales linearly |
| Scheduler init (1000 jobs) | ~400 μs | Still under 1ms |
| Config parsing (50 jobs) | ~566 μs | TOML parsing included |
| Config parsing (200 jobs) | ~2.9 ms | Large configs handled |
Memory Profile
| State | Memory |
|---|---|
| Idle (10 jobs) | ~2 MB |
| Idle (100 jobs) | ~3 MB |
| Running (10 concurrent) | ~5 MB |
Deployment
systemd Service
# /etc/systemd/system/flashcron.service
[Unit]
Description=FlashCron - Lightning-fast Cron Daemon
After=network.target
[Service]
Type=simple
User=flashcron
ExecStart=/usr/local/bin/flashcron run -c /etc/flashcron/config.toml
Restart=on-failure
RestartSec=5
Environment=RUST_LOG=info
[Install]
WantedBy=multi-user.target
Docker Compose
version: '3.8'
services:
flashcron:
image: ghcr.io/alfredo-baratta/flashcron:latest
volumes:
- ./flashcron.toml:/app/config/flashcron.toml:ro
- ./scripts:/scripts:ro
restart: unless-stopped
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
Kubernetes
apiVersion: apps/v1
kind: Deployment
metadata:
name: flashcron
spec:
replicas: 1
selector:
matchLabels:
app: flashcron
template:
metadata:
labels:
app: flashcron
spec:
containers:
- name: flashcron
image: ghcr.io/alfredo-baratta/flashcron:latest
resources:
requests:
memory: "8Mi"
cpu: "10m"
limits:
memory: "32Mi"
cpu: "100m"
volumeMounts:
- name: config
mountPath: /app/config
volumes:
- name: config
configMap:
name: flashcron-config
Comparison with Alternatives
| Feature | FlashCron | cron | fcron | systemd-timer |
|---|---|---|---|---|
| Memory usage | ~2-5 MB | ~1 MB | ~5 MB | N/A (systemd) |
| Config format | TOML | crontab | fcrontab | unit files |
| Hot reload | Yes | No | Yes | Yes |
| Retry support | Yes | No | Yes | Yes |
| Timeout | Yes | No | Yes | Yes |
| Concurrent limit | Yes | No | No | No |
| Cross-platform | Yes | Unix | Unix | Linux |
| Metrics | Optional | No | No | journald |
| Performance | Optimized | Standard | Standard | Standard |
Contributing
Contributions are welcome! See CONTRIBUTING.md for guidelines.
# Clone the repository
# Run tests
# Run benchmarks
# Build release
License
MIT License - see LICENSE for details.
Author
Alfredo Baratta - alfredobaratta@outlook.com
Acknowledgments
- cron - Cron expression parsing
- tokio - Async runtime
- clap - CLI framework
- tracing - Structured logging
Built for speed
Because every millisecond counts