How to schedule tasks with cron on Linux

Answered
Jan 05, 2026 1759 views 1 answers
1

I need to run a backup script every night at 2 AM. How do I set up a cron job?

H
Asked by hassan_ops
Bronze 565 rep

1 Answer

23

Edit crontab

# Edit user crontab
crontab -e

# Cron format: minute hour day month weekday command
# Run at 2:00 AM every day
0 2 * * * /path/to/backup.sh

# Run every 5 minutes
*/5 * * * * /path/to/script.sh

# Run on Sundays at midnight
0 0 * * 0 /path/to/weekly.sh

Useful cron examples

# View current crontab
crontab -l

# Run command with full paths
0 2 * * * /usr/bin/python3 /home/user/backup.py >> /var/log/backup.log 2>&1
S
Answered by sysadmin 1 week, 2 days ago
Silver 222 rep

Your Answer

You need to be logged in to answer questions.

Log In to Answer

Related Questions

Hot Questions

No hot questions available.