 |
|
Oracle Scheduling Using the Windows Job
Schedulers
Oracle Tips by Burleson Consulting |
Using the Windows Job Schedulers
AT.EXE
The AT command can be used to schedule commands
and programs on Windows NT, Windows 2000, Windows XP and Windows
2003. For the command to work, the scheduler service must be
running. On Windows 2000, this can be done using the services
dialog (Start --> Programs --> Administrative Tools --> Services) or
from the command line using the net command:
net stop
"Task Scheduler"
net start "Task Scheduler"
The at /? command produces the following:
AT [\\computername]
[ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
[ /EVERY:date[,...] | /NEXT:date[,...]] "command"
\\computername
Specifies a remote computer. Commands are scheduled on the
local computer if this parameter is omitted.
id
Is an identification number assigned to a scheduled
command.
/delete
Cancels a scheduled command. If id is omitted, all the
scheduled commands on the computer are canceled.
/yes
Used with cancel all jobs command when no further
confirmation is desired.
time
Specifies the time when command is to run.
/interactive
Allows the job to interact with the desktop of the user
who is logged on at the time the job runs.
/every:date[,...]
Runs the command on each specified day(s) of the week or
month. If date is omitted, the current day of the month
is assumed.
/next:date[,...]
Runs the specified command on the next occurrence of the
day (for example, next Thursday). If date is omitted, the
current day of the month is assumed.
"command"
Is the Windows NT command, or batch program to be run.
A couple of simple examples of its use include:
C:> at 21:00
/every:m,t,th,f "c:\jobs\MyJob.bat"
Added a new job with job ID = 1
C:> at 6:00
/next:20 "c:\jobs\MyJob.bat"
Added a new job with job ID = 2
The first example schedules a job which runs
the c:\jobs\MyJob.bat script at 9:00 p.m. on Mondays, Tuesdays,
Thursdays and Fridays. The second example schedules a job that
runs the script at 6:00 a.m. on the next 20th of the month.
User ID =
reader, Password = program
The current list of jobs can be displayed by
issuing the at command with no parameters:
C:\>at
Status ID Day
Time Command Line
--------------------------------------------------------------------
1 Each M T Th F
21:00 PM
c:\jobs\MyJob.bat
2 Next 20
06:00 AM
c:\jobs\MyJob.bat
C:\>
Jobs can be deleted using the /delete option:
C:\>at 1
/delete
C:\>at 2
/delete
C:\>at
There are no entries in the list.
C:\>
The AT scheduler has been at the heart of
Windows scheduling for some years, but recent Windows versions have
introduced simpler and more flexible alternatives, which will be
covered in the following section.
Scheduled Tasks Wizard
In Windows 2000, Windows XP, and Windows 2003
there is a GUI tool called the Scheduled Tasks Wizard, which is far
more convenient than the AT command. It is available from the
Control Panel or from the task bar (Start --> Programs -->
Accessories --> System Tools --> Scheduled Tasks). The
resulting dialog lists the current scheduled tasks and an Add
Scheduled Task icon, as seen in Figure 1.1.
Figure 1.1 ? Scheduled Tasks dialog with no
scheduled jobs
To schedule a new task, simply double click on
the Add Scheduled Task icon, which starts the Scheduled Tasks Wizard
as shown in Figure 1.2.
Figure 1.2 ? Scheduled Tasks Wizard
Clicking the Next button produces a list of
programs that can be scheduled as shown in Figure 1.3. If the
program or script that is desired is not available in the list, the
Browse button allows the user to select alternatives from the file
system.
Figure 1.3 ? Scheduled Tasks Wizard:
program list
Once the relevant command or script is
selected, clicking the Next button displays a screen that allows a
name and basic schedule to be associated with the task as shown in
Figure 1.4.
Figure 1.4 ? Scheduled Tasks Wizard: name
and basic schedule
The contents of the next screen vary depending
on the type of basic schedule selected. Figure 1.5 shows the
additional schedule information that can be defined for a daily
task.
Figure 1.5 ? Scheduled Tasks Wizard: additional
scheduling options
The next screen, Figure 1.6, permits
authorization credentials for the task to be assigned, allowing the
task to run as any valid operating system user. It is
important that tasks run with the correct credentials, as running
tasks under privileged accounts can introduce potential security
holes.
Figure 1.6 ? Scheduled Tasks Wizard:
authorization details
Finally, a summary page is displayed, as shown
in Figure 1.7, which gives the option of displaying the advanced
properties dialog once the job definition is complete. If this
option is left unchecked, clicking the Finish button displays the
original scheduled tasks list.
Figure 1.7 ? Scheduled Tasks Wizard:
summary
The newly scheduled task is now displayed in
the scheduled tasks dialog as shown in Figure 1.8.
Figure 1.8 ? Scheduled Tasks dialog with newly
scheduled job listed
Right clicking on the job and selecting the
Properties option from the pop-up menu in Figure 1.9, displays the
advanced properties dialog. This dialog allows the task
definition to be modified after it is created.
Figure 1.9 ? Scheduled job properties dialog
The following section will present the SCHTASKS
command which provides a more feature rich command line alternative
to the AT command.
 |
This is an excerpt from the book "Oracle
Job Scheduling" by Dr. Tim Hall. You can buy it direct
from the publisher for 30%-off and get instant access to the
code depot of Oracle job scheduling scripts. |