System
cron
cron and crontab commands for task scheduling.
30 commands
Windows
MacOS
Linux
#scheduling
#automation
Crontab Management
Edit the current user crontab
crontab -e
List the current user crontab entries
crontab -l
Remove the current user crontab
crontab -r
Edit crontab for a specific user
crontab -u username -e
List crontab for a specific user
crontab -u username -l
Load crontab from a file
crontab /path/to/crontab.txt
Schedule Syntax
Crontab field format reference
# m h dom mon dow command
Minute, Hour, Day, Month, Weekday
# * * * * * command
Valid ranges for each field
# 0-59 0-23 1-31 1-12 0-7
Run every 5 minutes
# */5 * * * * command
Run every 2 hours at minute 0
# 0 */2 * * * command
Common Schedules
Run at the top of every hour
0 * * * * /path/to/script.sh
Run daily at midnight
0 0 * * * /path/to/script.sh
Run every Sunday at midnight
0 0 * * 0 /path/to/script.sh
Run on the first of every month
0 0 1 * * /path/to/script.sh
Run weekdays at 6:30 AM
30 6 * * 1-5 /path/to/script.sh
Run every 10 minutes
*/10 * * * * /path/to/script.sh
System Cron
List system cron job files
ls /etc/cron.d/
List daily system cron scripts
ls /etc/cron.daily/
List hourly system cron scripts
ls /etc/cron.hourly/
View the system crontab
cat /etc/crontab
Check if cron service is running
sudo systemctl status cron
Troubleshooting
Check cron execution logs on Debian
grep CRON /var/log/syslog
Check cron logs via journalctl
journalctl -u cron
Log cron output to a file
* * * * * /path/to/script.sh >> /tmp/cron.log 2>&1
Verify script is in PATH
which script.sh
Capture cron environment for debugging
env > /tmp/cronenv.txt
Quick Commands
Edit the current user's crontab file
crontab -e
List all crontab entries for the current user
crontab -l
Schedule a script to run daily at midnight
0 0 * * * /path/to/script.sh