← Cron & Scheduling
Linux · Cron & Scheduling

How to create or edit a cron job in Linux

Add or edit a scheduled cron job with crontab -e, redirect its output to a log, and verify it was saved.


Add a scheduled job to your crontab. crontab -e opens it in an editor; save to install. Run as the user that should own the job.

crontab -e replaces your whole crontab when you save, so edit carefully. Cron runs with a minimal environment: use absolute paths and redirect output, or a failing job can go unnoticed.

# Edit your crontab
crontab -e

# Example line: run a backup daily at 01:00 and log output
# 0 1 * * *  /opt/scripts/backup.sh >> /var/log/backup.log 2>&1

# Install a crontab from a file instead
crontab /path/to/my.cron

# Verify what is now installed
crontab -l
Linuxcrontabcron