question

JGarcia-7651 avatar image
0 Votes"
JGarcia-7651 asked MotoX80 answered

Issue with Windows Server 2019 Task Scheduler

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DSPatrick avatar image
0 Votes"
DSPatrick answered

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://docs.microsoft.com/en-us/answers/topics/vs-general.html
https://docs.microsoft.com/en-us/answers/topics/dotnet-csharp.html
https://docs.microsoft.com/en-us/answers/topics/dotnet-visual-basic.html
https://docs.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--



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JennyYan-MSFT avatar image
0 Votes"
JennyYan-MSFT answered JGarcia-7651 commented

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://docs.microsoft.com/en-us/windows/win32/taskschd/tasksettings-priority



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

Thanks,
Jenny



· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I checked the priority in xml, the value is 5. It is the same priority as the old task in Windows Server 2008 since I just exported from the old server and imported into the new one.

0 Votes 0 ·
MotoX80 avatar image
0 Votes"
MotoX80 answered

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

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

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.