You are on page 1of 11

Objectives

After completing this unit, students should be able to:
Use crontab files to schedule jobs on a periodic basis
Use the at command to schedule a job or series of jobs
at some time in the future
Use the batch command to schedule jobs in a queue, to
alleviate immediate system demand
cron Daemon
Responsible for running scheduled jobs
Starts:
crontab command events
(regularly scheduled jobs)
at command events
(one time only execution at specified time)
batch command events
(run when CPU load is low)
crontab Files
Used to start regularly occurring jobs
Schedule is defined in
/var/spool/cron/crontabs/ $USER
Files to control users' crontab privileges
/var/adm/cron/cron.deny list user who cannot use
crontab
/var/adm/cron/cron.allow list user who can use
crontab
An empty cron.deny exists by default
To view current crontab
Format:
minute hour date month day-of-week command
# crontab -l
#
#COMPONENT_NAME: (CMDCNTL) commands needed for
#basic system needs
#
#0 3 * * * /usr/sbin/skulker
#45 2 * * 0 /usr/lib/spell/compress
#45 23 * * * ulimit 5000;
/usr/lib/smdemon.cleanu > /dev/null
0 11 * * * /usr/bin/errclear -d S,O 30
0 12 * * * /usr/bin/errclear -d H 90
crontab File
Editing crontab
To edit crontab file:
# crontab -e
Safer method:
# crontab -l > /tmp/crontmp
# vi /tmp/crontmp
# crontab /tmp/crontmp
The at and batch Commands
The at command submits a uniquely occurring job for
cron
# at now +2 mins
banner hello > /dev/tty3
<ctrl-d>
job user.time.a will be run at date
# batch
banner hello > /dev/tty3
<ctrl-d>
Controlling at Jobs
To list at jobs:
at -I [ user ]
atq [ user ]
To cancel a job:
at -r job
atrm [ job | user ]
# at -l
root.962649853.a Mon Jul 3 14:44:13 EDT 2000
root.962649886.a Mon Jul 3 14:44:46 EDT 2000
adm.962649912.a Mon Jul 3 14:45:12 EDT 2000
# at -r adm.962649912.a
The adm.962649912.a at file is deleted
Documenting Scheduling
Have a copy of user's crontab files
Have a copy of /etc/inittab
Exercise:
Scheduling
Exercise: Scheduling
Checkpoint
1. True or false? The at.allow and at.deny files must be used to
specify which users are allowed and denied use of the at
command.
2. Using cron, how would you specify a job to run every Thursday
at 10 past and 30 minutes past every hour?
___________________________________________________
3. How would you schedule the script "myscript" to run 10 minutes
from now?
___________________________________________________

Unit Summary
cron daemon is responsible for running scheduled jobs
crontab file holds schedule for recurring jobs
The at command is used to schedule a command for one
time only execution