AT
Updated: January 21, 2005
Schedules commands and programs to run on a computer at a specified time and date. You can use at only when the Schedule service is running. Used without parameters, at lists scheduled commands.
Syntax
at [[\\ComputerName] Hours:Minutes [/interactive] [{/every:Date[,...] | /next:Date[,...]}] Command]
Parameters
Remarks
- Schtasks is another command-line scheduling tool that you can use to create and manage scheduled tasks. For more information about schtasks, see Related Topics.
-
Using at
To use at, you must be a member of the local Administrators group.
- Loading Cmd.exe
At does not automatically load Cmd.exe, the command interpreter, before running commands. If you are not running an executable (.exe) file, you must explicitly load Cmd.exe at the beginning of the command as follows:
cmd /c dir > c:\test.out
- Viewing scheduled commands
When you use at without command-line options, scheduled tasks appear in a table formatted similar to the following:
Status ID Day Time Command Line
OK 1 Each F 4:30 PM net send group leads status due
OK 2 Each M 12:00 AM chkstor > check.file
OK 3 Each F 11:59 PM backup2.bat
-
Including identification number (ID)
When you include identification number (ID) with at at a command prompt, information for a single entry appears in a format similar to the following:
Task ID: 1
Status: OK
Schedule: Each F
Time of Day: 4:30 PM
Command: net send group leads status due
-
After you schedule a command with at, especially a command that has command-line options, check that the command syntax is correct by typing at without command-line options. If the information in the Command Line column is incorrect, delete the command and retype it. If it is still incorrect, retype the command with fewer command-line options.
- Viewing results
Commands scheduled with at run as background processes. Output is not displayed on the computer screen. To redirect output to a file, use the redirection symbol (>). If you redirect output to a file, you need to use the escape symbol (^) before the redirection symbol, whether you are using at at the command line or in a batch file. For example, to redirect output to Output.text, type:
at 14:45 c:\test.bat ^>c:\output.txt
The current directory for the executing command is the systemroot folder.
- Changing system time
Do not use a redirected drive for scheduled jobs that access the network. The Schedule service might not be able to access the redirected drive, or the redirected drive might not be present if a different user is logged on at the time the scheduled task runs. Instead, use UNC paths for scheduled jobs. For example:
at 1:00pm my_backup \\server\share
Do not use the following syntax, where x: is a connection made by the user:
at 1:00pm my_backup x:
- Tasks stopping after 72 hours
By default, tasks scheduled using the at command stop after 72 hours. You can modify the registry to change this default value.
- Click Start
- Click Run
- Type REGEDIT
- Click OK
- Double-click HKEY_LOCAL_MACHINE
- Double-click SYSTEM
- Double-click CurrentControlSet
- Double-click Services
- Double-click Schedule
- Click Edit
- Click New
- Click String Value
- On the Value Name give it AtTaskMaxHours
- For the Data type REG_DWORD Radix: Decimal Value Data: 0. A value of 0 in the value data field indicates no limit, does not stop. Values from 1 though 99 indicates the number of hours.
Caution
- Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on the computer.
-
Task Scheduler and the at command
You can use the Scheduled Tasks folder to view or modify the settings of a task that was created by using the at command. When you schedule a task using the at command, the task is listed in the Scheduled Tasks folder, with a name such as the following:At3478. However, if you modify an at task through the Scheduled Tasks folder, it is upgraded to a normal scheduled task. The task is no longer visible to the at command, and the at account setting no longer applies to it. You must explicitly enter a user account and password for the task.
Examples
at \\marketing
To learn more about a command with the identification number 3 on the Corp server, type:
at \\corp 3
To schedule a net share command to run on the Corp server at 8:00 A.M. and redirect the listing to the Maintenance server, in the Reports shared directory, and the Corp.txt file, type:
at \\corp 08:00 cmd /c "net share reports=d:\marketing\reports >> \\maintenance\reports\corp.txt"
To back up the hard drive of the Marketing server to a tape drive at midnight every five days, create a batch program called Archive.cmd, which contains the backup commands, and then schedule the batch program to run, type:
at \\marketing 00:00 /every:5,10,15,20,25,30 archive
To cancel all commands scheduled on the current server, clear the at schedule information as follows:
at /delete
To run a command that is not an executable (that is, .exe) file, precede the command with cmd /c to load Cmd.exe as follows:
cmd /c dir > c:\test.out
Formatting legend
Format | Meaning |
Italic | Information that the user must supply |
Bold | Elements that the user must type exactly as shown |
Ellipsis (...) | Parameter that can be repeated several times in a command line |
Between brackets ([]) | Optional items |
Between braces ({}); choices separated by pipe (|). Example: {even|odd} | Set of choices from which the user must choose only one |
Courier font | Code or program output |
Some of these terms may be the same or similar to DOS commands. For information on DOS Commands, click here