1. Problems encountered
Batch_D_Account batches run slowly on production machines, with an average running time of up to five hours, and then double-click to execute the batch running time when reloading is only three or four minutes.
2. Investigate the reasons
After many tests, it turns out that starting the program through the windows scheduled task is slower than manually starting the program by double-clicking. Check that the priorities of the two program processes are different, the scheduled task startup program is lower than the normal (B) priority, and the double-click startup is the normal (N) priority.
The final conclusion is that the low priority of the Windows scheduled task startup program causes the program to run slowly.
3. Solutions
Change the windows scheduled task configuration and set the priority to high. Specific steps are as follows:
1. Open the task scheduler library to run Batch_D_Account batches, and view the process priority in the task manager
2. Export Batch_D_Account task
3. Modify the Batch_D_Account task configuration file process priority to 0
4. Delete the Batch_D_Account task, as shown in the figure:
5. Import the modified Batch_D_Account task configuration file, as shown in the figure:
6. Run the scheduled task again and check that the priority of the Batch_D_Account.exe process is the highest in real time
7. Done, the program runs much faster.
Attachment: Process Priority Description
1. Process level: 0 is the highest priority for real-time
2. Process level: 10 is the lowest priority
3. Process level: 7 is the default priority
4. Process level: 7&8 are background tasks
5. Process level: 4&5&6 are interactive tasks
Collective look: https://msdn.microsoft.com/en-us/library/windows/desktop/aa383512(v=vs.85).aspx
Postscript: If it is wrong, please help to correct it, thank you!
<?xml version="1.0" encoding="UTF-16"?> <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"> <RegistrationInfo> <Date>2015-07-30T15:44:53.0156462</Date> <Author>T1HHAPWEBI01\admin_batch</Author> <Description>Merchant monthly flow download</Description> </RegistrationInfo> <Triggers> <CalendarTrigger> <StartBoundary>2015-07-30T08:10:00</StartBoundary> <Enabled>true</Enabled> <ScheduleByDay> <DaysInterval>1</DaysInterval> </ScheduleByDay> </CalendarTrigger> </Triggers> <Principals> <Principal id="Author"> <UserId>T1HHAPWEBI01\admin_batch</UserId> <LogonType>Password</LogonType> <RunLevel>HighestAvailable</RunLevel> </Principal> </Principals> <Settings> <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy> <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries> <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries> <AllowHardTerminate>true</AllowHardTerminate> <StartWhenAvailable>false</StartWhenAvailable> <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable> <IdleSettings> <StopOnIdleEnd>true</StopOnIdleEnd> <RestartOnIdle>false</RestartOnIdle> </IdleSettings> <AllowStartOnDemand>true</AllowStartOnDemand> <Enabled>true</Enabled> <Hidden>false</Hidden> <RunOnlyIfIdle>false</RunOnlyIfIdle> <WakeToRun>false</WakeToRun> <ExecutionTimeLimit>P3D</ExecutionTimeLimit> <Priority>0</Priority> <!-- Set the priority here--> </Settings> <Actions Context="Author"> <Exec> <Command>D:\Batch_file\Batch_D_Account\Batch_D_Account.exe</Command> </Exec> </Actions> </Task>