At (Windows)
In computing, at (at.exe
) is a command which schedules other commands to be run at a certain time. It may run a command once, or repeatedly based upon the day of the week, or the date. It is available on all Windows NT-based operating systems.
Each command is given a job number or "task ID", starting at 1. All unfinished or repeating jobs are reloaded at boot time, though not necessarily with the same job numbers. When there are no jobs left, the next job added is assigned 1 again; otherwise, all previously-assigned job numbers are skipped (even if the most recent has been deleted).
Scheduled tasks are not run if the computer is turned off at the time, or is in sleep mode or hibernate mode. The "Task Scheduler" service (Schedule) must also be running.
Unix-like operating systems also have at
, but the Windows version is functionally more similar to cron
.
Usage
By itself, at
gives a list of all pending jobs. By supplying a task ID, slightly more details of the task are displayed.
To shut down a computer at 10:00 in the evening:
at 10p shutdown -s
The above example will cause shutdown.exe to shut down the computer the next time the computer's clock reads 10pm. Synonyms for this time are 10:00p or 22:00; however 10 or 22 will not work. (Note that shutdown.exe is in one of the folders (normally C:\Windows\System32) listed in the %PATH% environment variable. Other commands will require the full file path.)
Commands can also be scheduled on other computers on a local-area network, using a remote procedure call (RPC). However, the user must be an administrator, have permission on the other machine, and the user account on both machines must have a password (RPC will refuse if passwords are blank). The UNC computer name is placed immediately after at
in order to do this, as follows:
at \\otherdesk 10p shutdown -s
The shutdown command is then scheduled on the remote computer named "otherdesk" (not locally), and will show in its list of jobs. A remote computer's jobs can also be checked as follows:
at \\otherdesk
Flags
Several flags greatly expand the usefulness of at
, allowing it to act similarly to cron
. All flags come before the command being scheduled.
The /every:
flag can be used to repeat a command at the same time, by using a date of the month, or abbreviations for the days of the week: m, t, w, th, f, s, su. Standard two- and three-letter abbreviations (except th and su) will cause the at
command to fail, however the full names of the days can also be used. If no day or date is given, the current date is assumed.
at 10p /every:m,t,w,th,f shutdown -s at 7p /every:s,su shutdown -s
The above commands will shut down the computer at 10:00 (22:00) every weekday evening, and at 7:00 (19:00) every weekend evening.
Similarly, the /next
flag runs the commands only on the first occurrence of each of the days or dates supplied. If either flag is used to schedule something on a date that does not exist in a given month (such as February 30), it will be skipped until the next month (in this case, March 30).
The /delete
or /d
flag will delete a job if its number is given, or all jobs if none is given. When used with it, the /yes
or /y
flag will do so without asking for confirmation.
The /interactive
or /i
flag will allow the command to interact with the user who is logged-on when the job runs, for example, to warn of a shutdown or to allow the user to cancel it.
Replacement
In Windows XP, the schtasks
command is much more powerful and flexible, but also much more complex. The Task Scheduler is the graphical user interface to schtasks
, and at
jobs will show in the task lists of both programs.
See also
References
|