Scheduling Tasks
Often, the best time to perform maintenance for performance and disaster recovery is late, late at night, when all the users are at home and asleep, and the servers and the network are at their quietest. The problem is that at that time of the night, all the administrators are also at home and fast asleep. So how should you get your maintenance tasks running at two o'clock in the morning? Why, the Task Scheduler is your tool to do this, of course.
The Task Scheduler is located in Control Panel > System and Maintenance > Administrative Tools. It has a new look and feel in Windows Vista, and has features and capabilities like never before.
The old Task Scheduler in Windows XP and even in Windows Server 2003 was (is) pretty basic; to use it, you followed these steps:
- Select an executable or script to run.
- Input credentials to run the task.
- Set the schedule.
You were done in about three steps.
The new Task Scheduler has a large library of preconfigured, system-related tasks. Some tasks are active and are already performing their duties in the background. Some tasks are lying dormant, waiting for someone to set a valid trigger to activate them.
As shown in Figure 3.22, the library of preconfigured tasks covers a wide range of targets.
Figure 3.22 Preconfigured Windows tasks are available in the Task Scheduler.
To make adjustments to the existing tasks, click the Properties hyperlink in the Actions pane on the right. This brings up the configuration details, as shown in Figure 3.23. The General tab shows which credentials are used to run the task.
Figure 3.23 The properties of a scheduled task.
A new setting on the Conditions tab is to start the task only if a specified network connection is available. The Settings tab has a new option on what to do if an instance of the task is already running. The choices include
- Do Not Start a New Instance
- Run a New Instance in Parallel
- Queue a New Instance
- Stop the Existing Instance
And finally, the History tab shows a log of activity related to this one task.
Tasks are now recorded in XML files. These XML files can be easily exported and imported onto other Windows Vista computers.
Command-Line Task Scheduler Tools
Surprisingly, the old AT command-line Task Scheduler tool is still around and kicking. But the recommended command-line tool to use is called SchTasks.exe. This tool isn't new in Vista but is newer than AT.
While SchTasks can't use triggers other than the clock, and can launch only executables and scripts, you can use SchTasks with these switches to perform the following functions regarding scheduled tasks:
- Run—Launches the scheduled task immediately
- End—Stops the currently running scheduled task
- Query—Displays all scheduled tasks
- Change—Changes the properties of the scheduled task
- Create—Creates a new scheduled task
- Delete—Deletes the scheduled task(s)
You should be familiar with these basic functions available with this command-line utility for the exam.