Home/Glossary/Cron Job

Cron Job

A scheduled task that runs automatically at specified times or intervals on Unix-like operating systems.

AutomationAlso called: "scheduled task", "cron schedule"

Cron jobs automate repetitive tasks like backups, reports, and maintenance.

Components

  • Cron expression: Defines when to run (minute, hour, day, month, weekday).
  • Command/script: What to execute.
  • User context: Which user runs the job.
  • Output: Where logs/errors go (email, file).

Common uses

  • Database backups (daily at midnight).
  • Log rotation (weekly cleanup).
  • Report generation (monthly summaries).
  • Health checks (every 5 minutes).
  • Certificate renewal (automated Let's Encrypt).

Best practices

  • Log all job output for debugging.
  • Use absolute paths in scripts.
  • Set appropriate timeouts.
  • Handle failures gracefully.
  • Test in non-production first.
  • Document what each job does.

Alternatives

  • Systemd timers (Linux).
  • Task Scheduler (Windows).
  • Cloud schedulers (AWS EventBridge, Cloud Scheduler).