Você está na página 1de 10

Unit 8

Scheduling

© Copyright IBM Corporation 2009


Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.2
Unit objectives
IBM Power Systems

After completing this unit, you should be able to:


• Understand the role of the cron daemon
• 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

© Copyright IBM Corporation 2009


The cron daemon
IBM Power Systems

• 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)

© Copyright IBM Corporation 2009


crontab files
IBM Power Systems

• Used to start regularly occurring jobs

• Schedule is defined in:


/var/spool/cron/crontabs/$USER

• Files to control crontab privileges of users:


– /var/adm/cron/cron.deny lists users who cannot use
crontab
– /var/adm/cron/cron.allow lists users who can use
crontab

• An empty cron.deny exists by default.

© Copyright IBM Corporation 2009


Format of a crontab file
IBM Power Systems

Format of entries:
minute hour date-of-month month day-of-week command

To view current crontab:


# crontab -l

...
...
#0
#0 33 ** ** ** /usr/sbin/skulker
/usr/sbin/skulker
#45
#45 22 ** ** 00 /usr/lib/spell/compress
/usr/lib/spell/compress
#45
#45 23
23 ** ** ** ulimit
ulimit 5000;
5000; /usr/lib/smdemon.cleanu
/usr/lib/smdemon.cleanu >> /dev/null
/dev/null
00 11 * * * /usr/bin/errclear -d
11 * * * /usr/bin/errclear -d S,O 30 S,O 30
00 12
12 ** ** ** /usr/bin/errclear
/usr/bin/errclear -d-d HH 90
90
00 15
15 * * * /usr/lib/ras/dumpcheck >/dev/null
* * * /usr/lib/ras/dumpcheck >/dev/null 2>&1
2>&1
0,30,45
0,30,45 * * * * /usr/sbin/dumpctrl -k >/dev/null 2>/dev/null
* * * * /usr/sbin/dumpctrl -k >/dev/null 2>/dev/null
...
...

© Copyright IBM Corporation 2009


Editing a crontab file
IBM Power Systems

• One way to edit a crontab file:


## crontab
crontab -e
-e

• A safer method:

## crontab
crontab -l
-l >> /tmp/crontmp
/tmp/crontmp
## vi /tmp/crontmp
vi /tmp/crontmp
## crontab
crontab /tmp/crontmp
/tmp/crontmp

© Copyright IBM Corporation 2009


The at and batch commands
IBM Power Systems

• The at command submits a uniquely occurring job to be run


by cron at a specified time.

## at
at 55 pm
pm Friday
Friday
banner
banner hello
hello >> /dev/pts/0
/dev/pts/0
<ctrl-d>
<ctrl-d>
job
job user.time.a
user.time.a will
will be
be run
run at
at date
date
## for
for hosts
hosts in
in lpar50
lpar50 lpar51
lpar51 lpar52
lpar52
do
do
rsh
rsh $host
$host "echo
"echo '<<EOF
'<<EOF nohup
nohup shutdown
shutdown -Fr'
-Fr' || at
at now
now ""
done
done

• The batch command submits a job to be run when the


processor load is sufficiently low.
## batch
batch
banner
banner hello
hello world
world >> /dev/pts/0
/dev/pts/0
<ctrl-d>
<ctrl-d>

© Copyright IBM Corporation 2009


Controlling at jobs
IBM Power Systems

• To list at jobs:
at -l [user]
atq [user]
## at
at –l
–l
root.1118077769.a
root.1118077769.a Mon
Mon Jun
Jun 66 10:09:29
10:09:29 2007
2007
root.1118078393.a
root.1118078393.a Mon
Mon Jun 6 10:19:53 2007
Jun 6 10:19:53 2007
test2.1118079063.a
test2.1118079063.a Mon
Mon Jun
Jun 66 10:31:03
10:31:03 2007
2007

• To cancel an at job:
at -r job
atrm [job | user]
## at
at -r
-r test2.1118079063.a
test2.1118079063.a
at
at file: test2.1118079063.a
file: test2.1118079063.a deleted
deleted

• To cancel all your at jobs:


atrm -

© Copyright IBM Corporation 2009


Documenting scheduling
IBM Power Systems

• Have a copy of each user's crontab file


• Have a copy of the /etc/inittab file

Scheduling Records

© Copyright IBM Corporation 2009


Unit summary
IBM Power Systems

Having completed this unit, you should be able to:


• Understand the role of the cron daemon
• 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

© Copyright IBM Corporation 2009

Você também pode gostar