1
I need to run a backup script every night at 2 AM. How do I set up a cron job?
Loading...
Q&A · Answered
I need to run a backup script every night at 2 AM. How do I set up a cron job?
Accepted answer
# 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
# View current crontab
crontab -l
# Run command with full paths
0 2 * * * /usr/bin/python3 /home/user/backup.py >> /var/log/backup.log 2>&1Say what you tried, not only what worked — the next person needs the reasoning. Code goes in a fenced block.