Crontab / Cron Reference
Crontab commands, schedule expressions, and common scheduling examples
Your data never leaves the browser — all processing is done locally 0 server requests
Basic crontab Commands
-
crontab -eEdit your crontab (changes take effect immediately on save)
-
crontab -lList your current crontab entries
-
crontab -rRemove all your crontab entries ※ deletes without confirmation, use with caution
-
sudo crontab -u 사용자 -lView another user's crontab entries
-
sudo systemctl status cronCheck the cron daemon status (use crond on RHEL-based systems)
-
cat /etc/crontabView the system-wide crontab (6-field format including user column)
Schedule Expressions — 5-Field Syntax
Fields left to right: minute(0-59) hour(0-23) day(1-31) month(1-12) weekday(0-7, both 0 and 7 = Sunday). * means any value, */n means every n, a-b is a range, a,b is a list.
-
* * * * * 명령Run every minute
-
*/5 * * * * 명령Run every 5 minutes
-
0 * * * * 명령Run at the top of every hour
-
30 2 * * * 명령Run every day at 02:30 AM
-
0 9 * * 1-5 명령Run at 9:00 AM on weekdays (Mon–Fri)
-
0 0 * * 0 명령Run at midnight every Sunday
-
0 0 1 * * 명령Run at midnight on the 1st of every month
-
0 0,12 * * * 명령Run at midnight and noon every day
-
0 4 1 1 * 명령Run at 04:00 on January 1st every year
Special Strings (Shortcuts)
-
@reboot 명령Run once at system startup
-
@hourly 명령Run at the top of every hour (same as 0 * * * *)
-
@daily 명령Run at midnight every day (same as @midnight)
-
@weekly 명령Run at midnight every Sunday
-
@monthly 명령Run at midnight on the 1st of every month
-
@yearly 명령Run at midnight on January 1st every year (same as @annually)
Tips — Environment, Logging & Overlap Prevention
Cron runs in a minimal environment different from your login shell. Always use absolute paths for commands and files to be safe.
-
SHELL=/bin/bashSet the shell to use at the top of the crontab
-
PATH=/usr/local/bin:/usr/bin:/binDefine PATH at the top of the crontab (prevents "command not found" errors)
-
MAILTO=""Disable email notifications for job output
-
0 3 * * * /home/user/backup.sh >> /var/log/backup.log 2>&1Redirect both stdout and stderr to a log file
-
*/10 * * * * flock -n /tmp/job.lock /path/job.shSkip if the previous run is still going, preventing overlapping jobs
Verification & Debugging
-
grep CRON /var/log/syslogCheck cron execution history (Debian/Ubuntu)
-
sudo tail -f /var/log/cronFollow cron logs in real time (RHEL/CentOS)
-
journalctl -u cron --since todayView today's cron logs in a systemd environment
-
dateCheck the server's current time and timezone (timezone mismatch can cause unexpected run times)
-
ls /etc/cron.daily/List system scripts that run automatically every day
Crontab: Scheduling Tasks on Linux
Cron is the standard task scheduler on Unix-like systems. Each line in a crontab file defines a job with a 5-field time expression followed by the command to run: minute (0–59), hour (0–23), day of month (1–31), month (1–12), day of week (0–7, where 0 and 7 are Sunday).
Common patterns: */5 * * * * (every 5 minutes), 0 2 * * * (daily at 2 AM), 0 9 * * 1-5 (weekdays at 9 AM). Use crontab -l to list jobs and crontab -r to remove all jobs (be careful with -r).
⚠ crontab -r removes ALL cron jobs without confirmation. Always run crontab -l first to review your jobs before deleting them.
FAQ
- How do I edit my crontab?
- Run crontab -e to open the cron table in your default editor. Add one job per line using the 5-field format: minute hour day month weekday command. Save and exit to activate.
- What does */5 mean in a cron expression?
- "Every 5 units." For example, */5 in the minutes field means "every 5 minutes." The * means "all valid values" and /5 means "every 5th one."
- My cron job is not running — how do I debug it?
- Common causes: wrong path (cron uses a minimal environment, so use absolute paths), missing execute permission on the script, or silent errors. Redirect output: * * * * * /path/to/script.sh >> /tmp/cron.log 2>&1 to capture both stdout and stderr.