Scheduling Jobs from Command Line
|
Posted Thursday, 20 September 2007 by Michael Khanin
If you need create a schedule jobs on any remote computer or server you can use an AddTaskAppRuns.bat and run it from the command line (On central server) by using PSEXEC.EXE. In my example, AddTaskAppRuns.bat contain:
schtasks /create /ru DOMAIN-NAME\User-from-domain /rp password-of-domain-user /sc minute /mo 1 /tn "AppRuns" /tr C:\Updates\AppRuns.bat
The following command schedules a script, AppRuns.bat, to run every 1 minutes. Because the command does not include a starting date or time, the task starts 1 minutes after the command completes, and runs every 1 minutes thereafter whenever the system is running. Notice that the AppRuns.bat script source file is located on drive C:\ in directory Updates (C:\Updates\ ) on the remote computer or servers where should run a schedule jobs.
Remarks
- SchTasks.exe performs operations similar to those in Scheduled Tasks in Control Panel. You can use either tool to create, delete, configure, or display scheduled tasks.
- Typing schtasks without any parameters performs a query.
- The user must be a member of the Administrators group on the computer that the command affects.
- To verify that a scheduled task ran or to find out why a scheduled task did not run, see the Task Scheduler service transaction log, Systemroot\SchedLgU.txt. This log records attempted runs initiated by all tools that use the service, including Scheduled Tasks and SchTasks.exe.
- On rare occasions, task files become corrupted. Corrupted tasks do not run. When you try to perform an operation on corrupted tasks, SchTasks.exe displays the following error message:
ERROR: The data is invalid.
- You cannot recover corrupted tasks. To restore the task scheduling features of the system, use SchTasks.exe or Scheduled Tasks to delete the tasks from the system and reschedule them.
- SchTasks.exe replaces At.exe, a tool included in previous versions of Windows.
|