Cron Cheatsheet

Crontab syntax, scheduling patterns, and automation of recurring tasks

Task Scheduling6 commandsbeginner

Overview

Cron is a time-based job scheduler for Unix/Linux systems.

Why It Matters

Cron is essential for scheduling regular tasks and automating system maintenance.

Essential Commands

crontab -e

Edit current user cron jobs

crontab -l

List current user cron schedule

0 2 * * * /usr/bin/backup.sh

Run script daily at 02:00

*/5 * * * * /usr/bin/php /app/job.php

Run job every 5 minutes

0 0 * * 0 /usr/bin/logrotate

Run task weekly on Sunday midnight

MAILTO="[email protected]"

Send cron output to email address

Quick Start

Master use crontab -e to edit schedules first

Key Concepts

Use crontab -e to edit schedules

Understand minute, hour, day, month, weekday syntax

Debug cron issues with logs

Pro Tips

  • Combine multiple commands for powerful workflows
  • Use aliases to speed up your command entry
  • Create scripts to automate repetitive tasks

Common Pitfalls to Avoid

  • Forgetting to check the documentation for edge cases
  • Running commands without understanding their full impact
  • Not testing changes in a safe environment first

Related Resources

9 items