A network administrator’s job is never done. Think of all the things you have to do in one day: keep antivirus applications up to date, patch and secure the intranet server, and apply the latest service packs and software updates on all of top management’s laptops before their 6:30 A.M. trip to southeast Asia. Add to that a typical day of keeping track of 10,000 workstations and 300 servers, and you’ve got a pretty full day.
Try as you may, you can’t do it all yourself. Wouldn’t it be nice to have a little help? Lucky for you, the help you need is right on your servers. With task schedulers, you can automate some of those tedious chores that keep you so busy. In this Daily Drill Down, I’ll show you how.
A tale of two utilities
There are two methods that can be used for scheduling tasks: the AT command and the Windows Task Scheduler. The AT command was first introduced with Windows NT 3.51. The Windows Task Scheduler appeared in Windows NT 4 and uses a much friendlier GUI and wizard to assist you in automating tasks.
Each method has its advantages and disadvantages. I will look first at the AT command, covering what it does and how it might be useful to you. Then I will dissect the Scheduled Task Wizard, explaining how it makes the AT command a friendlier tool to all, especially for those who like to stay as far away from the command prompt as possible.
Where it’s AT
The AT command is a command-line-based script. You can run the AT command on your local server or on any remote machine on your network. Using the AT command, you can make your Windows server execute a script, program, or batch file on any given date or time.
As with most command-line utilities, AT has a few switches you can use to customize what the command can do. Unlike most command utilities, AT has two sets of syntaxes, each of which do a slightly different thing. The first basic syntax for the AT command is as follows:
AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
Within this syntax:
- · \\computername represents the name of the computer that the AT command should affect. If you are running the AT command locally, you can omit the computer name. If you omit the computername switch, AT will assume the name of the local machine.
- · id stands for the ID of the scheduled command.
- · /DELETE deletes any or all scheduled commands.
- · When used with the /DELETE switch, the /YES switch causes AT to delete the scheduled jobs without asking for input from the user.
You’ll use this syntax most often when you’re scheduling and rescheduling sets of commands as part of a larger script file.
Click here to see the second syntax for AT.
Within this syntax:
- · time specifies the time when the command is to run, based on a 24-hour clock.
- · INTERACTIVE tells the AT command to allow the scheduled command to interact with the desktop when it’s running.
- · /EVERY runs the command on a specific date. If this switch is omitted, AT uses the current date. When selecting the date, you can enter a specific date, day of the month, or day of the week. When entering multiple selections, separate each one with a comma. If you want to enter a day of the week, use M, T, W, Th, F, S, and Su to represent the day you want. If you want the command to run on the same day each month, just enter the number of the day, omitting the month. For example, to run the command on the 15th of each month, enter 15.
- · /NEXT runs the command at the next occurrence of the specified day. For example, if you use both /NEXT and Sunday the command will run next Sunday.
- · command represents the command string that you wish to execute.
AT, practically speaking
Let’s take a look at a practical example of how you’d use the AT command. For the purposes of this example, I will name the server iggy, and your boss’s login id will be ciousa1.
Suppose that your boss has just come in from a client meeting and informed you that he will be leaving for the eastern regional office in Tokyo to oversee the operation in that office. He will need to be kept up to speed on things at the home office while he is gone. He has asked you to send him a copy of the sales reports issued for the next meeting so that he will be able to conduct that meeting via conference call. He leaves in the morning and the meeting is in a week.
You could simply fax the report or e-mail it; however, the e-mail servers’ scheduled maintenance is Tuesday evening around 11:45 P.M., the meeting is Wednesday at 8 A.M., and the sales report is generated the morning of the meeting at 6:45 A.M. The timing makes this a sticky situation, but since the Tokyo office is on your network and visible by administrators, you will still be able to reach your boss’s laptop.
With the huge workload on your desk, it would take an extra set of hands to see that this little request from the boss happens before the meeting. This is where the AT command comes in. To accomplish this entire task, you’ll need to do the following things:
- 1. Create a batch file, called Copysales.bat, to copy the sales report from the file server in the home office to the CEO’s laptop.
- 2. Schedule Copysales.bat to run at 7:15 A.M. on Wednesday to ensure that the file is placed in the My Documents folder on ciousa1 in time for the meeting.
- 3. Send a message to your boss to let him know that you’ve placed the file and where to look on his laptop to find it.
For the first step, you don’t need to do anything fancy. You don’t need the AT command at all. Just create a batch file that copies the information from the file server to the boss’s My Documents folder.
You’ll start using the AT command at step 2. To schedule the batch job to run one time at 7:15 A.M. Wednesday morning, enter the following:
AT \\iggy 07:15 /next:W “copysales.bat”
To send a message to your boss to let him know the file is there, schedule another command to run at 7:20 A.M. Wednesday. Enter the following syntax to send a message to the boss:
AT \\iggy 07:20 /next:W “net send CIOUSA1 Sales Report copied to My Documents”.
Scheduling these two jobs with AT will save you a lot of headaches. By taking five minutes to prepare the job now, you won’t have to think about it again until the appropriate file is ready. To view these scheduled commands, and any other commands scheduled by the AT command, just enter AT with no switches from the server’s command prompt.
Now let’s try the same examples with the much more up-to-date GUI-driven wizard. The Task Scheduler service that ships with Windows NT 4 (and now with Windows 2000) is much more user-friendly—for everyone from the most console-savvy administrator to the basic end user. It provides the same functionality as the AT command but with a pretty interface.
To accomplish your boss’s request (above), start the Scheduled Task Wizard by clicking Start | Settings | Control Panel | Scheduled Task | Add Scheduled Task.
The first screen displayed by the wizard is the welcome screen. Click Next to proceed. The next screen, as shown in Figure A, shows you a list of available programs on your system for which you might wish to schedule a job.
|Use the Scheduled Task Wizard to select a program to schedule.|
Note that this screen contains only a basic list of applications. You can select additional programs simply by clicking the Browse button and scouring your system or network for the file you wish to schedule. I will choose the Copysales.bat program that I created above. After you’ve browsed for the program you want to schedule, click Next to continue.
You’ll then see the Task Name screen shown in Figure B. On this screen, you will select a title for the task in the Task Name field. This doesn’t have to be the same as the filename you chose in the previous step. You should make the name something meaningful, so you’ll know what the task does when viewing a list of all scheduled tasks. You can also choose your scheduling options on this screen.
|You can name your task and set its schedule.|
Select the scheduling option you want and then click Next. The following screen will vary depending on the scheduling option you choose. This screen will contain the information you’ll need to set the exact time for the options you’ve chosen. For example, Figure C shows the options you can pick from if you choose the Weekly scheduling option. If you’ve chosen a different scheduling option, your screen will look slightly different.
|Narrow down the time in which you want the task to occur.|
You can schedule a task to run at any time, day or night, on any day of the week. Just be sure to keep things standard among all IT staff, so that all planned server reboots and downtimes can be accommodated by this schedule. You can modify this at any time, however. Scheduling around downtimes will save the administrative headaches that would be caused if you remembered at the last minute that you were supposed to back up the boss’s folders to the server prior to the downtime beginning in three hours.
In the next screen, shown in Figure D, you’ll provide the appropriate rights to the wizard so that the task can run. You’ll have to enter a username and password for a user ID with the appropriate rights to execute the task.
|Enter the user ID and password for a user to run the task.|
The username listed in the wizard by default will be that of the individual logged on when scheduling the task. In this example, I’ve used the Administrator account. If administrators typically schedule tasks in your organization, your username will also be that of the Administrator account. Note that Administrator access should be used sparingly because it can create security problems on your network.
Click Next when you have entered the necessary information corresponding to the appropriate level of access needed. You’ll then see the final screen in the Scheduled Task Wizard, shown in Figure E. This completion screen shows a summary of the job that the wizard created. This screen provides you with the option of viewing advanced details about the job. Click Finish.
|Review the details of the task and complete the scheduling process.|
Task schedulers can assist administrators and end users alike. They can save time, sometimes money, and even the occasional trip to the office at three in the morning to reboot the monitoring server. Now that you have seen the ways Windows 2000 will allow you to automate tasks in your enterprise environment, use the tools often and let your OS lend a helping hand in your rigorous job of maintaining a great enterprise networking solution.