1.4 KiB
1.4 KiB
Using Linux Terminal 2.3: Crontab format and location
A user crontab with a repeating job and a boot job, a system job in
/etc/cron.d, and keeping one user away from crontab.
Before you start
The lab creates users student and alice (password Lab-Pass-1), puts
a harmless script at /usr/local/bin/cleanup, and makes sure cron is
running. It saves /etc/cron.allow and /etc/cron.deny (if they exist)
and puts them back on reset. Task 1 needs a few minutes of waiting and a
reboot.
Tasks
- As
student(sudo -iu student), add a cron job that appends the date to~/ticks.logevery two minutes, and one that writesbootedto~/boot.logat every boot. Wait until~/ticks.loghas a date or two, then reboot and look at~/boot.log. - Make a system job that runs
/usr/local/bin/cleanupas root at 3:15 am on the first day of every month, in its own file under/etc/cron.d. - Stop
alicefrom using crontab, without touching anyone else: hercrontab -lsays she isn't allowed, andstudent's still works.
Hints
crontab -e,crontab -l;*/2 * * * *and@reboot;>>appends,>overwrites.- Files in
/etc/cron.dhave a user field after the five time fields, and cron skips files whose names contain a dot. /etc/cron.denylists users who may not use crontab; acron.allowwould shut out everyone it doesn't list.