Windows scheduled tasks get slower over time

Windows scheduled tasks get slower over time

Windows task scheduler is a powerful tool. Recently I had to troubleshoot a problem were Windows scheduled tasks get slower over time. So slow that it caused further problems. Read here about the problem and the solution.

Problem

At a customers backup server a very strange behavior was observed. After a few days without problems, scheduled tasks never seem to get finished. So a current running – never ending – task prevents the next run from starting. A reboot of the server resolved the problem – for a few days.

Solution

After a research I found out, scheduled tasks get started with a lower priority than interactively started tasks. See my scheduled PowerShell script in screenshot here.

Normally this is not a big deal. It does not matter when tasks like reports last longer than manually started. Nevertheless they should at least finish.

The solution is to rise the priority of scheduled tasks. Unfortunately this cannot simply be set in the GUI. It can be done in a few steps, I list here.

  1. Start Windows Task Scheduler, right-click your task and select Export… and save XML file to a temporary location.
  2. Edit XML file with an editor of your choice. Search for <Priority>7</Priority> and replace digit 7 by 4. Save file again. This sets tasks priority to the priority interactive tasks gets. This includes memory priority as well.
  3. Create a new task by importing edited XML file. To do so, click Action and Import Task … in Task Scheduler.
  4. After you selected your XML file, Create Task windows appears. All settings of your task respectively your XML file are already set. If you did not delete your old task, you need to change Name of the new task. Otherwise press OK.

A running scheduled task should now show Normal priority in Task Manager. It should also finish within normal timeframe continuously.

Notes

  • I tested it with Windows Server 2016. From my perspective the situation is the same in Server 2019.
  • To schedule a PowerShell script, select Action Start a program and powershell.exe (absolute path for a different PowerShell version) for Program.

    As arguments use -NoProfile -WindowStyle Hidden -file path_to_file.

One response to “Windows scheduled tasks get slower over time”

  1. Ina Dinjes says:

    You are a very good observer! Thanks for posting this :).

Leave a Reply

Your email address will not be published. Required fields are marked *