Docs / Linux Basics / Crontab Syntax and Scheduling Tasks

Crontab Syntax and Scheduling Tasks

By Admin · Feb 25, 2026 · Updated Apr 24, 2026 · 29 views · 1 min read

What is Cron?

Cron is the standard Linux task scheduler. It runs commands at specified times and intervals, making it essential for backups, log rotation, maintenance scripts, and more.

Editing Crontab

# Edit current user crontab
crontab -e

# Edit root crontab
sudo crontab -e

# List current crontab
crontab -l

Crontab Syntax

# ┌───── minute (0-59)
# │ ┌───── hour (0-23)
# │ │ ┌───── day of month (1-31)
# │ │ │ ┌───── month (1-12)
# │ │ │ │ ┌───── day of week (0-7, 0 and 7 = Sunday)
# │ │ │ │ │
# * * * * * command

Common Examples

# Every 5 minutes
*/5 * * * * /root/scripts/check.sh

# Daily at 3:30 AM
30 3 * * * /root/scripts/backup.sh

# Every Monday at 9 AM
0 9 * * 1 /root/scripts/weekly-report.sh

# First day of each month at midnight
0 0 1 * * /root/scripts/monthly-cleanup.sh

# Every hour during business hours (9-17), weekdays only
0 9-17 * * 1-5 /root/scripts/sync.sh

Special Strings

@reboot    /root/scripts/startup.sh   # Run once at boot
@hourly    /root/scripts/hourly.sh    # 0 * * * *
@daily     /root/scripts/daily.sh     # 0 0 * * *
@weekly    /root/scripts/weekly.sh    # 0 0 * * 0
@monthly   /root/scripts/monthly.sh   # 0 0 1 * *

Best Practices

  • Always redirect output: command >> /var/log/cron.log 2>&1
  • Use absolute paths for commands and scripts
  • Test scripts manually before adding to cron
  • Use MAILTO=admin@example.com at the top to receive error notifications

Was this article helpful?