Skip to content
Super v1.1.9 is here! 🎉 See the changelog

Scheduled Tasks (Cron)

Cron Scheduling 💎

Premium only — Cron scheduling requires superd-premium. OSS superd rejects cron on create/update/stack apply; see Config Reference — 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 Premium natively supports Cron-based Scheduled Tasks.

Configuration

To turn a standard program into a scheduled task, simply 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:

  1. No Autostart: Even if autostart is true, the process will not start immediately when the daemon boots. It will remain in the Stopped state until the cron scheduler triggers it.
  2. Success (Exit 0): When the job finishes successfully (exit code 0), Super marks it as Stopped. It does not attempt to restart it. It simply waits for the next cron tick.
  3. Failure (Exit != 0): If the job fails, Super marks it as Fatal and immediately fires a process_fatal system event. Pair with Event Notifications to alert Slack/Teams/DingTalk on failure.

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.sh

You can also manually trigger a cron job out of schedule for testing purposes using the standard start command:

super start daily-cleanup

Related