Windows Server 2008 R2 Unleashed (273 page)

BOOK: Windows Server 2008 R2 Unleashed
10.56Mb size Format: txt, pdf, ePub

Task Scheduler

1383

33

FIGURE 33.14

The error reporting screen.

curring tasks into a central location, administrators gain insight into system functionality

and control over their Windows Server 2008 R2 infrastructure through automation. These

things together assist administrators in the areas of logging and debugging.

ptg

Windows Server 2008 R2 improves upon the previous version of the Scheduled Task tools

included in Windows Server 2003 by allowing scheduled jobs to run more securely and

with greater predictability. One of the most compelling new features of the Task Scheduler

is that it fully integrates with Event Viewer. As such, a task can be triggered based on an

event captured in the event log. This is a great feature because administrators can be auto-

matically notified when a specific event transpires.

Understanding Task Scheduler

Scheduling tasks involves triggers and actions. A task runs once it is triggered. Tasks are

initiated by triggers that are based on an event or time. Multiple triggers can be associated

with a task as defined by an administrator. An action represents the work being performed

as the task is being executed. Examples of actions include starting a program or sending

an email. When a task is running multiple actions, up to 32 can be performed.

An additional functionality is task conditions. When a task is triggered, it will only run if

specific defined conditions are met. Task conditions eliminate ambiguous situations by

providing criteria-based functions. By improving on the Task Scheduler’s functionality, it

has become a very powerful and extensive development and activation tool for automat-

ing and assisting with troubleshooting tasks.

With Windows Server 2008 R2, Task Scheduler has been moved from Control Panel to

Administrative Tools. The new user interface is displayed in Figure 33.15.

1384

CHAPTER 33

Logging and Debugging

FIGURE 33.15

The Task Scheduler user interface.

ptg

Tasks are created by selecting Create Basic Task, Create Task, or Import Task from the

Actions pane in the Task Scheduler snap-in. When creating a task, there are five tabs of

options that must be configured. They include general settings, triggers, actions, conditions,

and additional settings. The upcoming sections explain the options when creating tasks.

Understanding Trigger Options and Settings

The first thing to consider when configuring a task is what triggers will cause the task to

execute. Triggers can be based on time, events, or various system states. As noted earlier,

each task can contain multiple triggers. With more than one trigger, the task will launch

when any of the conditions in any of the triggers is met.

The following describes the various trigger types and the settings that can be configured

for each type:

.
On a Schedule—
Triggers for a schedule allow tasks to run on a specific date (one

time), Daily, Weekly, or Monthly. For reoccurring tasks, the start time can be config-

ured along with reoccurring options to completely customize when the task will run.

.
At Log On—
Tasks scheduled to run when At Log On is set for any user or for a

specific user or group of users.

.
At Startup—
There are no specific settings for tasks configured to run at startup. This

type of trigger runs whenever the system starts and the only settings are the

advanced ones, which are described later in the chapter.

Task Scheduler

1385

.
On Idle—
The settings for tasks set to run when the computer is idle are set on the

Conditions tab.

.
On an Event—
This trigger causes a task to run when specific events are created in

an event log. You can choose either a basic event trigger or custom event settings.

Basic settings fire based on a single event from a specific event log. You choose

which log contains the event, the publisher name, and the event ID. If you specify

the custom event trigger settings, you can specify an XML event query or custom

event filter to query for events that will fire the task.

33

NOTE

It’s easier to create event-based triggers from within the event log unless you know

exactly what event(s) you want to trigger. See the section “Customizing the Event Log”

earlier in this chapter for a detailed explanation of how to create events from within

the event log.

.
At Task Creation/Modification—
Tasks created with this trigger are fired as soon as

they are created or whenever they are modified. The only settings for this trigger are

ptg

the advanced settings as described in the next section, “Understanding the

Advanced Settings Associated with Triggers.”

.
On Connection to User Session—
The trigger fires when a user connects to the

system using the Remote Desktop Connection program from another system and

can be set to run when any user connects, or when a specific user or group connects

to the server.

.
On Disconnect from User Session—
This trigger works the same as the On

Connection to User Session; however, it fires when users disconnect from the server

from a Remote Desktop Connection session. The trigger can be set to run for all

users or a specific user or group.

.
On Workstation Lock—
The trigger fires when the workstation is locked. The

settings for this trigger enable you to set it for all users or a specific user or group.

.
On Workstation Unlock—
This trigger fires when the workstation is unlocked. The

settings for this trigger enable you to set it for all users or a specific user or group.

Understanding the Advanced Settings Associated with Triggers

Advanced settings exist when creating triggers. Familiarize yourself with these advanced

settings to ensure trigger creation and the workflow process is fully optimized. The follow-

ing bullets explain each of the advanced settings associated with triggers:

.
Delay Task for or Delay Task for Up To (Random Delay)—
Tasks can be delayed

randomly so that they do not start immediately when the schedule triggers a task.

For systems that might run the same tasks, this ensures there is some load balancing

1386

CHAPTER 33

Logging and Debugging

and that all systems do not run tasks at exactly the same time. Random delays can

be set for 30 seconds, 1 minute, 30 minutes, 1 hour, 8 hours, or up to 1 day.

.
Repeat Task Every—
Tasks can also be set to repeat at regular intervals and for a set

duration (for example, a task could be set to ping a particular system every minute

for 1 day, write an event to the event log in the case of a failure, and email a distrib-

ution group to notify the IT team about the issue).

.
Stop Any Task If It Runs Longer Than—
Tasks can be stopped if they run past a

defined amount of time and can be set to expire at a certain date and time.

.
Start and Expire—
Start and Expiration times can be set to synchronize across time

zones to ensure tasks set to run on systems in multiple time zones start and stop at

the same time.

.
Enabled—
Tasks can be enabled or disabled by checking or unchecking the enabled

box.

Understanding the Actions Associated with a Task

As mentioned earlier, an action is the work conducted when a task runs. Tasks can have a

single action or up to a maximum of 32 actions. The Actions tab of a task contains a list of

actions associated with a particular task. An administrator can edit each action as follows:

ptg

.
Start a Program—
This action starts a program or script. In the Program/Script text

box, type either the name of the program or script that should be run. Alternatively,

the administrator can browse the application or script. If further command-line

arguments are required, these can be specified in the Add Arguments (Optional) text

box. In the Start In (Optional) text box, the working directory can be specified for

the command line that executes the program or script. This path is either the path

to the program or script or to the files that are used by the executable.

.
Send an E-mail—
This action sends an email when the task is triggered. In the Edit

Action dialog box, you enter who the email is from, who it should be sent to, a

subject, and any desired text. You must also enter a valid SMTP server.

.
Display a Message—
This action simply displays a message on the console of the

system where the task is created. You can enter a title for the message as well as any

text that should be displayed. This type of action only launches if the Run Only If

User Is Logged On security option has been selected on the General tab of the Task

Properties in the Create Task dialog box.

Understanding Conditions Associated with a Task

Conditions in conjunction with triggers determine whether the task will run. Tasks will

not run if any condition associated with a given task is not fulfilled. The following

sections illustrate the types of conditions associated with a task:

.
Idle Conditions—
A trigger can be based on idle time of a computer. Idle time is

checked by the Task Scheduler service every 15 minutes. Computers are idle if a

screensaver is running. When a screensaver is not running, the computer is consid-

Task Scheduler

1387

ered to be idle if for 15 minutes the CPU usage and disk input or output were at 0%

for 90% of the overall time. In this situation, mouse or keyboard input should also

be nil during this period of time. The Task Scheduler service only waits for user

input to mark the end of an idle state.

.
Power Conditions—
Administrators can specify that tasks run only on computers

operating on AC power. If administrators do not want a task to run when a

computer is on battery power, a condition must be set to stop the task. Also, if the

computer is off, a condition can be set to awaken the computer from a Sleep or

Hibernate mode so the task can run. Although this is unlikely in a server environ-

33

ment, it’s still an option.

.
Network Conditions—
Administrators can choose to start a task only if a specified

network connection is available. This setting is appropriate if the action requires

access to a remote system or network.

NOTE

The Network Conditions do not support interoperability with Windows 2000 or XP.

Understanding Task Settings

ptg

The Settings tab of the Tasks Properties or Create Task dialog box offers settings that help

you control how the task is run, restarted, stopped, or deleted, as follows:

.
Allow Task to Be Run on Demand—
If selected, this setting enables the adminis-

trator to manually start the task regardless of triggers or conditions by selecting the

tasks and clicking Run in the Actions pane or right-clicking the task and selecting

Run from the context menu.

.
Run Task as Soon as Possible After a Scheduled Start Is Missed—
If this option

is selected, a task that has been scheduled to start at a specific time but did not run

(for example, the computer was off or the scheduler service was busy) will be started,

but only after 10 minutes has elapsed from the original start time.

.
If the Task Fails, Restart Every—
This setting controls what to do when a task does

not run (for example, if a task fails to start a service due to an undetermined system

problem). If this option is selected, an administrator can also configure the number

of attempts that should be made to initiate the task.

.
If the Running Task Does Not End When Requested, Force It to Stop—
If a

task does not respond to a request to stop, an administrator can set a condition to

force it to stop.

.
Stop the Task If It Runs Longer Than—
If this item is checked, a limit on how

long the task can run is enforced. As a result of this setting, a task might not be

completed when it is stopped.

.
If the Task Is Not Scheduled to Run Again, Delete It After—
This selection

helps the administrator keep the Task Scheduler MMC free from old tasks that might

Other books

Mango Lucky by Myers, Bill
The Game of Lives by James Dashner
The End of Country by Seamus McGraw
EMS Heat 01 - Running Hot by Stephani Hecht
The Joys of Love by Madeleine L'engle
The Lion and the Rose by May Sarton
Murder on Sagebrush Lane by Patricia Smith Wood
Mine by Brett Battles