Issue with Windows Server 2019 Task Scheduler

JGarcia 6 Reputation points
2021-07-20T20:29:18.293+00:00

I have this program that searches a directory for files and uploads the file data to a backend system. It used to run as a scheduled task in Windows Server 2008 R2 machine - here, the program has worked fine for years and usually completes successfully after a few minutes. When I take this same program and set it up to run as a scheduled task in Task Scheduler on a Windows Server 2019 machine, I do not get the same behavior. The program often executes very slowly and eventually times out because it takes too long trying to process files into the backend. The program also writes to logs regularly as it runs, but on Windows Server 2019, logs are not written until the timeout. Also, a week ago, this same program on Windows Server 2019 would sometimes complete successfully (even though its slow still), now it never runs to completion. What's with the completely different behavior on the two machines? I heard there was a bug introduced in Server 2016 - the workaround was to use a One Time trigger that runs indefinitely (like in this link: https://rudimartinsen.com/2017/07/05/differences-and-bugs-in-windows-2016-task-scheduler/) instead of a daily trigger. I tried this workaround, but I still have the same issue. I do not see any problems or errors in Event Viewer when it attempts to run, also the CPU usage looks pretty normal during program execution. The program also runs normally when I debug it in my IDE on my local machine, so the issue only comes when it is setup in Task Scheduler. Any help is much appreciated.

Windows Server 2019
Windows Server 2019
A Microsoft server operating system that supports enterprise-level management updated to data storage.
4,032 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Anonymous
    2021-07-20T20:46:57.107+00:00

    Unfortunately we couldn't even hazard a guess, we've no idea the inner working of the program. The application developer will be your best resource to troubleshoot. If you are the developer then I'd try asking for help in dedicated forums here.
    https://learn.microsoft.com/en-us/answers/topics/vs-general.html
    https://learn.microsoft.com/en-us/answers/topics/dotnet-csharp.html
    https://learn.microsoft.com/en-us/answers/topics/dotnet-visual-basic.html
    https://learn.microsoft.com/en-us/answers/topics/windows-api-general.html

    --please don't forget to upvote and Accept as answer if the reply is helpful--

    0 comments No comments

  2. Jenny Yan-MSFT 9,351 Reputation points
    2021-07-21T07:00:21.827+00:00

    Hi,

    Have you verified the priority settings when checking scheduled task xml format?
    One user shared his situation of PowerShell will not run scripts or complete any commands when launched through a scheduled task due to timeout.

    Powershell stalls when run from a scheduled task
    https://www.reddit.com/r/PowerShell/comments/d8a02v/powershell_stalls_when_run_from_a_scheduled_task/

    TaskSettings.Priority property
    https://learn.microsoft.com/en-us/windows/win32/taskschd/tasksettings-priority

    ----------

    If the Answer is helpful, please click Accept Answer and upvote it.

    Thanks,
    Jenny


  3. MotoX80 35,716 Reputation points
    2021-07-21T19:55:20.52+00:00

    I would suggest using Process Monitor to trace the program's file and network activity to see what it's doing.

    https://learn.microsoft.com/en-us/sysinternals/downloads/procmon

    https://www.bing.com/search?q=how+to+use+process+monitor

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.