Skip to content

Linux cron Guide

Mattscreative edited this page Dec 5, 2025 · 2 revisions

⏰ Linux cron Guide

Complete beginner-friendly guide to cron on Linux, covering Arch Linux, CachyOS, and other distributions including installation, crontab configuration, and scheduled tasks.


Table of Contents

  1. Understanding cron
  2. cron Installation
  3. Crontab Configuration
  4. Cron Syntax
  5. Troubleshooting

Understanding cron

What is cron?

cron schedules tasks to run automatically.

Components:

  • cron daemon: Runs scheduled tasks
  • crontab: User's cron configuration
  • cron jobs: Scheduled commands

Common uses:

  • Backups: Automated backups
  • Updates: System updates
  • Maintenance: Regular maintenance

cron Installation

Install cron

Arch/CachyOS:

# Install cronie
sudo pacman -S cronie

# Enable service
sudo systemctl enable --now cronie

Debian/Ubuntu:

sudo apt install cron

Fedora:

sudo dnf install cronie

Verify Installation

Check cron:

# Check service
systemctl status cronie

# Check crontab
crontab -l

Crontab Configuration

Edit Crontab

Edit user crontab:

# Edit crontab
crontab -e

# List crontab
crontab -l

# Remove crontab
crontab -r

System Crontab

System-wide:

# Edit system crontab
sudo vim /etc/crontab

# Or add to /etc/cron.d/

⏰ Cron Syntax

Cron Format

Cron syntax:

* * * * * command
│ │ │ │ │
│ │ │ │ └── Day of week (0-7, 0 or 7 = Sunday)
│ │ │ └──── Month (1-12)
│ │ └────── Day of month (1-31)
│ └──────── Hour (0-23)
└────────── Minute (0-59)

Examples

Common examples:

# Every minute
* * * * * command

# Every hour
0 * * * * command

# Daily at midnight
0 0 * * * command

# Weekly on Sunday
0 0 * * 0 command

# Monthly on 1st
0 0 1 * * command

Troubleshooting

Cron Not Running

Check service:

# Check cron service
systemctl status cronie

# Check logs
journalctl -u cronie

# Or cron log
grep CRON /var/log/syslog

Job Not Executing

Check crontab:

# List crontab
crontab -l

# Check syntax
# Use absolute paths
# Set environment variables

Summary

This guide covered cron installation, crontab configuration, and scheduled tasks for Arch Linux, CachyOS, and other distributions.


Next Steps


This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.

Clone this wiki locally