Scheduled Tasks (Cron)
Process managers are traditionally used for long-running daemons (like web servers). However, managing periodic tasks (like database backups or log cleanups) usually forces you to fall back to the system’s crontab, which lacks centralized logging, alerting, and observability.
Super natively supports cron-based scheduled tasks in the open-source superd binary.
Configuration
To turn a standard program into a scheduled task, add the cron field to its configuration. Super uses an extended cron expression format (Seconds, Minutes, Hours, Days, Months, Day of Week).
[[programs]]
name = "db-backup"
command = "/scripts/backup.sh"
# Run at 02:00 AM every day
cron = "0 0 2 * * *"State Machine Differences
When a program has a cron expression, Super fundamentally changes how it manages the process lifecycle:
- No Autostart: Even if
autostartistrue, the process will not start immediately when the daemon boots. It will remain in theStoppedstate until the cron scheduler triggers it. - Success (Exit 0): When the job finishes successfully (exit code
0), Super marks it asStopped. It does not attempt to restart it. It simply waits for the next cron tick. - Failure (Exit != 0): If the job fails, Super marks it as
Fataland fires aprocess_fatalsystem event. Pair with Event Hooks (OSS) or licensed Event Notifications (notifyplugin) for external alerting.
Preventing Overlap
What happens if a job takes longer to run than the interval between its scheduled times? (e.g., a backup takes 2 hours, but it runs every 1 hour).
Super prevents overlaps by design. If a cron job is triggered but its previous instance is still Running, Super will skip the new tick and log a warning. Your system will never be flooded with overlapping jobs.
CLI Usage
You can create cron jobs directly from the CLI:
super add --name daily-cleanup --cron "0 0 3 * * *" /scripts/cleanup.shYou can also manually trigger a cron job out of schedule for testing purposes using the standard start command:
super start daily-cleanup