AU147vE0 Cron

11

Click here to load reader

description

free

Transcript of AU147vE0 Cron

Page 1: AU147vE0 Cron

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

Page 2: AU147vE0 Cron

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)

Page 3: AU147vE0 Cron

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

Page 4: AU147vE0 Cron

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/null0 11 * * * /usr/bin/errclear -d S,O 300 12 * * * /usr/bin/errclear -d H 90

crontab File

Page 5: AU147vE0 Cron

Editing crontab

To edit crontab file:

# crontab -e

Safer method:

# crontab -l > /tmp/crontmp

# vi /tmp/crontmp

# crontab /tmp/crontmp

Page 6: AU147vE0 Cron

The at and batch Commands

The at command submits a uniquely occurring job for cron

# at now +2 minsbanner hello > /dev/tty3<ctrl-d>job user.time.a will be run at date

# batchbanner hello > /dev/tty3<ctrl-d>

Page 7: AU147vE0 Cron

Controlling at Jobs

To list at jobs:

at -I [ user ]atq [ user ]

To cancel a job:

at -r jobatrm [ job | user ]

# at -l

root.962649853.a Mon Jul 3 14:44:13 EDT 2000root.962649886.a Mon Jul 3 14:44:46 EDT 2000adm.962649912.a Mon Jul 3 14:45:12 EDT 2000

# at -r adm.962649912.aThe adm.962649912.a at file is deleted

Page 8: AU147vE0 Cron

Documenting Scheduling

Have a copy of user's crontab files

Have a copy of /etc/inittab

Page 9: AU147vE0 Cron

Exercise:

Scheduling

Exercise: Scheduling

Page 10: AU147vE0 Cron

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?

___________________________________________________

Page 11: AU147vE0 Cron

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