NETW0001 - Week 4, Day 4 — Cron & Scheduled Tasks

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/17

encourage image

There's no tags or description

Looks like no tags are added yet.

18 Terms

1
New cards

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.

2
New cards

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.

3
New cards

What does crontab -e do?

Edit the current user's cron jobs.

4
New cards

What does crontab -l do?

Lists the current user's cron jobs.

5
New cards

Why should you never run crontab -r ?

It removes all jobs with no confirmation and no undo.

6
New cards

Where are user crontabs stored?

User crontabs are stored in /var/spool/cron/crontabs/

7
New cards

Where are system-wide crontabs stored?

System-wide crontabs live in /etc/crontab (with an extra user field) and /etc/cron.d/

8
New cards

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.

9
New cards

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.

10
New cards

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.

11
New cards

What does * * * * * command mean?

Every minute, every day.

12
New cards

What does 0 7 * * 1-5 command mean?

7:00am Monday to Friday.

13
New cards

What does 0 2 5,15 * * command mean?

2:00am on the 5th and 15th.

14
New cards

What does 0 0 1 * * command mean?

Midnight on the 1st of every month.

15
New cards

What does */5 * * * * command mean?

Every 5 minutes.

16
New cards

What does 30 7 * * 1 command mean?

7:30am every Monday.

17
New cards

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.

18
New cards

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.