1/17
Looks like no tags are added yet.
What is cron?
A daemon that wakes up every minute and checks whether any scheduled jobs need to run. Like Windows Task Scheduler — but configured as a plain text file and running since the 1970s on every Unix-like system.
What is the crontab syntax?
minute (0-59), hour (0-23), day of month (1-31), month (1-12), day of week (0-6, Sunday=0). Special values: = any, /5 = every 5 units, 1,15 = on the 1st and 15th, 1-5 = range Monday through Friday.
What does crontab -e do?
Edit the current user's cron jobs.
What does crontab -l do?
Lists the current user's cron jobs.
Why should you never run crontab -r ?
It removes all jobs with no confirmation and no undo.
Where are user crontabs stored?
User crontabs are stored in /var/spool/cron/crontabs/
Where are system-wide crontabs stored?
System-wide crontabs live in /etc/crontab (with an extra user field) and /etc/cron.d/
Where are drop-in directories stored?
Drop-in directories: /etc/cron.daily/, /etc/cron.weekly/, /etc/cron.monthly/ — scripts placed here run at the specified frequency.
What does command >> /var/log/job.log 2>&1 do and why is the 2>&1 important?
Redirects job output to a file instead of the user’s mail. The 2>&1 is important — without it, errors go to mail while normal output goes to the file.
What does grep CRON /var/log/syslog | tail -20 do?
Shows recent cron activity including what ran and when. This is the standard way to verify a job actually executed.
What does * * * * * command mean?
Every minute, every day.
What does 0 7 * * 1-5 command mean?
7:00am Monday to Friday.
What does 0 2 5,15 * * command mean?
2:00am on the 5th and 15th.
What does 0 0 1 * * command mean?
Midnight on the 1st of every month.
What does */5 * * * * command mean?
Every 5 minutes.
What does 30 7 * * 1 command mean?
7:30am every Monday.
What’s the difference between anacron and cron?
cron only runs a job if the system is on at the scheduled time. If you schedule a 2am backup and the server was off, the backup doesn't run. anacron ensures missed jobs run when the system next starts — it's used for the /etc/cron.daily, /etc/cron.weekly, /etc/cron.monthly directories.
When would you use /etc/cron.daily/ instead of a crontab entry?
When you don't care exactly when it runs, just that it runs once per day. Simpler to manage than a crontab entry for maintenance scripts.