Task Scheduling Flashcards
What is the at utility?
Allows scheduling the execution of one time command in the future
How do you schedule a command to run with at?
i.e at 21:00
at now +1 minute
logger “Uptime is $(uptime)” *to save press ctrl + d twice
How do you view all at jobs?
atq
How do you remove an at job?
atrm {jid}
How do you control access over who can use the at command?
Create file in /etc/
at.deny whitelists everyone except in the file
at.allow blacklists everyone except in the file
Only one of these can exist in /etc/
What is cron?
Allows scheduling or reoccurring commands
how do you control access over who can use the cron command?
Create file in /etc/
cron. deny whitelists everyone except in the file
cron. allow blacklists everyone except in the file
Where are system cron jobs stored?
/etc/crontab
What is the syntax for scheduling a cron job?
m h dom m dow u com
i.e * * * * * root ping abc.xyz -c 1»_space; ~/ping
minute, hour, day of month, month, day of week, user, command. Only user field exists for system cron
Where can files be placed to be run by cron?
/etc/cron.hourly/
/etc/cron.daily/
/etc/cron.weekly/
/etc/cron.monthly/
What executes scripts placed in different cron folders?
/etc/anacrontab
anacron ensures jobs run that have missed their window
/etc/cron.d/0hourly is the same but specifically for hoursly jobs as anacron enables specifying a delay for pending jobs to be run
How do you create a custom job in anacron and run it immediately to test?
Edit /etc/anacrontab
(period in days) (delay in minutes) (job-identifier) (command)
anacron
- f force run jobs
- n force run jobs serially ignoring delays
How does anacron keep track of which jobs need to be run in the event they have missed their window?
The job-identifier in /etc/anacrontab is used by anacron to check the last time the job was ran. It is located in /var/spool/anacron/