At scheduled to run commands and programs on the computer at the specified time and date _dos/bat

Source: Internet
Author: User
Tags naming convention time and date net send schtasks
The AT program runs the commands and programs on the computer at the specified time and date. The AT command can only be used when the schedule service runs. If used without parameters, at lists the scheduled commands.

Grammar
at [\\ComputerName] [{[ID] [/delete]|/delete [/yes]}]

at [[\\ComputerName] hours:minutes [/interactive] [{/every:date[,...]| /next:date[,...]}] Command

Parameters
\\computername
Specifies the remote computer. If this argument is omitted, the at schedule commands and programs on the local computer.
Id
Specifies the identification code assigned to the scheduled command.
/delete
Cancels the scheduled command. If an ID is omitted, all scheduled commands on the computer are canceled.
/yes
When you delete a scheduled event, all queries from the system are answered yes.
Hours:minutes
Specifies the time that the command runs. The time is represented by a 24-hour (that is, hours from 00:00 [midnight] to 23:59): the minute format.
/interactive
Allows command to interact with the user's desktop for the user who is logged on when the command is run.
/every:
Runs the command command on a specified day of the week or month (for example, every Thursday, or the third day of the month).
Date
Specifies the date on which the command was run. You can specify a day or days of the week (that is, type M, T, W, Th, F, S, Su), or a day or days in one months (that is, type a number from 1 to 31). Separate multiple date items with commas. If date is omitted, at uses the current day of the month.
/next:
Runs the command when the next specified date (for example, next Thursday) arrives.
Command
Specifies the Windows command, program (. exe or. com file) or batch program (. bat or. cmd file) to run. When the command requires a path as an argument, use an absolute path, which is the entire path starting with the drive letter. If the command is on a remote computer, specify the Universal naming convention (UNC) symbol for the server and share name, not the remote drive letter.
/?
Display Help at the command prompt.
Comments
Schtasks is a more powerful superset of command-line scheduling tool that contains all the features in the AT Command line tool. For all command-line scheduling tasks, you can use schtasks instead of at. For more information about schtasks, see.

Using at
When you use the AT command, you are required to be a member of the local Administrators group.

Load Cmd.exe
Before running the command, at does not automatically load the Cmd.exe (command interpreter). If you do not run an executable file (. exe), you must specifically load the Cmd.exe at the beginning of the command by using the method shown below:

cmd/c dir > C:\test.out.

View a scheduled command
When you use at with no command-line options, the scheduled task appears in a table similar to the following format:

Status ID Day, 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
Include identification number (ID)
When you use the AT command with an identification number (ID) at the command prompt, the information for a single task item is displayed 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
When you plan to have the AT command (especially a command with command-line options), you can check that the command syntax is entered correctly by typing an at with no command-line options. If the information displayed in the command line column is incorrect, delete the command, and then retype it. If it is not, you can leave it with less command-line options when you retype the command.

View Results
Run as a background program using the already scheduled command at. The results of the run are not displayed on your computer. To redirect output to a file, use the redirection symbol (>). If you redirect output to a file, you need to use an escape character (^) before the redirection symbol, whether you use at the command line or in a batch file. For example, to redirect output to a Output.text file, type:

At 14:45 C:\test.bat ^>c:\output.txt

The current directory that executes the command is the systemroot folder.

Change system time
After you schedule a command to run with the AT command, and if you change the system time of the computer, you can synchronize the at scheduler with the modified system time by typing an at with no command-line options.

Store command
The scheduled commands are stored in the registry. This way, if you restart the Schedule service, you will not lose the scheduled task.

Connecting to a network drive
For scheduled jobs that require access to the network, do not use redirected drives. The scheduled service may not be able to access these redirected drives, or these redirected drives may not appear if other users are logged on while the scheduled task is running. Therefore, for scheduled jobs, use a UNC path. For example:

At 1:00pm My_backup \\server\share

Do not use the following syntax, where x:? Represents a connection made by a user:

At 1:00pm my_backup x:

If you plan to connect a shared directory using the AT command with the drive letter, include an at command to disconnect the drive when the drive is complete. If you cannot disconnect from the drive, the assigned drive letter is not available at the command prompt.

Example
To display a list of SCHEDULED commands on the Marketing server, type:

At \\marketing
To learn more about the command with identification number 3 on the server Corp, type:

At \\corp 3
To schedule a network share command to run on the Corp server at 8:00 and redirect the list to the maintenance server's Corp.txt file (located under the Reports shared directory), 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, first create a batch program named Archive.cmd (which contains a backup command), and then schedule the batch program to run, so you type:

At \\marketing 00:00/every:5,10,15,20,25,30 Archive
To cancel all the commands that are already scheduled on the current server, clear the at schedule information as follows:

At/delete
If the command you want to run is not an executable (. exe) file, use CMD/C to load the Cmd.exe before the command, as shown in the following way:

cmd/c dir > C:\test.out.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.