You are on page 1of 4

SCHEDULING

Scheduling: Schedulinghas three types:


1.
2.
3. batch

at
cron

1. at: Runs commands at a later time.it is a one time scheduling command.


To
Schedule
Jobs
to
Run
at
a
Later
Time
at [ -c | -k | -s | -qQueue] [ -m ] [ -fFile ] { -tDate |Time [ Day ] [ Increment ] }
he atcommand reads from standard input the names of commands to be run at a later time
and
allows
you
to
specify
when
the
commands
should
be
run.
The at command mails you all output from standard output and standard error for the
scheduled commands, unless you redirect that output. It also writes the job number and the
scheduled time to standard error.
When the at command is executed, it retains the current process environment. It does not
retain open file descriptors, traps, and priority.To schedule a job to run at a later time, you
must specify a time to start the job. You may specify the time by using either the -tDate flag
or the Time, Day, and Increment parameters. At most, 60 jobs can be scheduled in any given
run queue at the granularity of one per second. If more jobs than can be handled are
submitted, for every job beyond 60, a file _at<pid> is created in /var/spool/cron/atjobs/ which
can be safely deleted by the end user.
The Datevariable to the -t flag is specified using the following format:
[[CC]YY]MMDDhhmm[.SS]
The digits in the Date variable are defined as follows:
CC

Specifies the first two digits of the year (the century).

YY

Specifies the second two digits of the year.

MM Specifies the month of the year (01 through 12).


DD Specifies the day of the month (01 through 31)./td>
hh

Specifies the hour of the day (00 through 23).

mm Specifies the minute of the hour (00 through 59).


SS

Specifies the second of the minute (00 through 59).

#at

submits a job for cron to run at a specific time in the


future
(at -f /home/root/bb_at -t 2007122503)

#echo <command> |

this starts in the background (and you can log off)

at now
at now +2 mins
#banner hello >
/dev/pts/0
<ctrl-d>

(at now + 1 minute,at 5 pm Friday )

#/var/adm/cron/at.deny

allows any users except those listed in this file to


use the at command.

#/var/adm/cron/at.allow allows only those users listed in this file to use the
at command (including root).
#at -l

Lists at jobs

#atq [user]

Views other users jobs (Only root can use this


command.)

#at -r

Cancels an at job

#atrm job

Cancels an at job by job number

#atrm user

Cancels an at job by the user (root can use it for


any user; users can cancel their jobs.)

#atrm

Cancels all at jobs belonging to the user invoking


the atrm command

e.g
To schedule the command from the terminal, enter a command similar to one of the
following:
If
sysadmin
is
at
5
sysadmin
<Ctrl-D>
If
sysadmin
is
at
now
$HOME/bin/sysadmin
<Ctrl-D>

in

your

in
+

current
pm

directory,

$HOME/bin/sysadmin,
2

enter:
Friday

enter:
days

Note:
When entering a command name as the last item on the command line, a full
path name must be given if the command is not in the current directory, and the
at command will not accept any arguments.

2.
Crontab:Submits,
edits,
lists,
or
removes
cron
crontab [-e [UserName] | -l [UserName] | -r [UserName] | -v[UserName] | File ]

jobs.

The crontab command submits, edits, lists, or removes cron jobs. A cron job is a command
run by the cron daemon at regularly scheduled intervals. To submit a cron job, specify the
crontab command with the -e flag. The crontab command invokes an editing session that

allows you to create a crontab file. You create entries for each cron job in this file. Each
entry must be in a form acceptable to the cron daemon. For information on creating entries,
see
The
crontab
File
Entry
Format.
Security
Only the root user or the owner of the crontab file can use UserName following the -e, -l,-r,
and x-small;>-v flags to edit, list, remove, or verify the crontab file of the specified user.
Controls
on
/var/adm/cron/cron.allow

Using
the
crontab
Command
File containing users who allowed cron service

/var/adm/cron/cron.deny

File containing users denied cron service

/var/adm/cron/at.allow

File containing users who allowed at service

/var/adm/cron/at.deny

File containing users denied at service

# crontab e
changes user can save and quit.

This command will open Vi editor and after making

# crontab l

Command will list all the jobs scheduled.

# crontab r
this command will remove all the cron jobs. You should be
very careful in running these commands in production environment.
The crontab File Entry Format
A crontab file contains entries for each cron job. Entries are separated by newline characters.
Each crontab file entry contains six fields separated by spaces or tabs in the following form:
minute
hour
day_of_month
month
weekday
command
These fields accept the following values:
minute

0 through 59

hour

0 through 23

day_of_month 1 through 31
month

1 through 12

weekday

0 through 6 for Sunday through Saturday

command

a shell command

e.gSep 1 12:30 AM is represented as:


30

00

* <command>

To write the time to the console every hour on the hour, enter:

0****
>/dev/console

echo

The

hour

is

`date`

To run the calendar command at 6:30 a.m. every Monday, Wednesday,


and Friday, enter:

30
6
*
*
1,3,5
/usr/bin/calendar
3. batch: Runs jobs when the system load level permits.i.e system is average.
Batch
The batch command reads from standard input the names of commands to be run at a later
time and runs the jobs when the system load level permits. The batch command mails you all
output from standard output and standard error for the scheduled commands, unless you
redirect that output. It also writes the job number and the scheduled time to standard error.
When thebatch command is executed, it retains variables in the shell environment, and the
current directory; however, it does not retain open file descriptors, traps, and priority.
The batch command is equivalent to entering the at -q b -m now command. The -q b flag
specifies the at queue for batch jobs.
Examples
To
run
a
job
when
the
system
load
permits,
enter:
batch <<!
longjob
!This example shows the use of a Here Document to send standard input to the batch
command.
Files
/usr/bin/batch

Contains the batchcommand.

/bin/batch

Symbolic link to the batch command.

/var/adm/cron

Indicates the main crondaemon directory.

/var/spool/cron/atjobs

Indicates the spool area.

Designed by

You might also like