Select to view content in your preferred language

Scheduled Model Builder Failing Overnight

181
5
04-08-2025 05:41 AM
Labels (3)
marksm_macomb
Frequent Contributor

Hi all,

I have a simple model that replaces the data in a hosted feature service with data from a SQL server database. I would like this to run every night. When I run the model in my pro project, it works great, but I have yet to have a successful run overnight using Windows Task Scheduler. After some research and talking briefly with tech support (they are able to give me limited support as they don't really deal with WTS), here is everything that I have tried:

  • Making sure "run whether user is logged on or not" and "run with highest privileges" settings are turned on in Windows Task Scheduler.
  • Creating another task to run a batch file to open ArcGIS Pro before running the model
    • Here's my batch file that I got from Esri support, only thing I changed is that I increased the timeout time to give the model plenty of time to run before closing Pro:
    • echo Opening up ArcGIS Pro
       
      start /b C:\Program Files\ArcGIS\Pro\bin\ArcGISPro.exe
       
      echo waiting 7000 seconds
      timeout 7000
       
      echo closing ArcGIS Pro
      Taskkill /IM ArcGISPro.exe /T /F
       
      echo Closing ArcGIS Pro and ending the batch file
       
  • Making sure my computer's settings enable wake timers, increasing the amount of time before my computer goes to sleep, and making sure WTS is set to "wake the computer to run this task" under conditions.

Another weird thing is that even after changing all of these settings, my tasks are set to run at 12:00AM (batch file to open pro) and 12:30AM (scheduled model builder), but they are actually running at varying times just after 6AM. I feel I am close with the idea that I need Pro open in order to run the model, since I'm needing to connect to my SQL database connection and AGO credentials, but I'm hitting a wall since the batch file I tried is not doing the trick.

This is my first time trying to schedule a model like this so any help is appreciated.

Here is the model:

marksm_macomb_0-1744115869105.png

Here's what I see when I check if it has run in the morning, there are no helpful messages along with it:

marksm_macomb_1-1744115946263.png

 

0 Kudos
5 Replies
MichaelVolz
Esteemed Contributor

Have you checked Event Viewer for any errors?

Would you be willing to save model as python script and try running it from python with error catching that might yield some clues on why it is not running?

0 Kudos
marksm_macomb
Frequent Contributor

Event Viewer and Windows task scheduler both are showing that the tasks are starting and completing successfully, but ArcGIS Pro history is showing it failed. I will attempt today to run it from python and see if I get different results. I'm new to this so very much figuring it out as I go.

0 Kudos
royceSimpson1
Emerging Contributor

I'm having what seems to be the same issue.  I can set up a model to run via the scheduler option, run the task manually in Pro from the History tab, then the "Run Now" option, and it runs just fine (takes about 5 minutes to complete).  If I then go to Windows Task Scheduler and change from "Run only when user is logged on" to "Run whether user is logged on or not", then follow the same "Run Now" process as before, in Pro, the task runs for about 4 seconds, then just terminates without having done anything. 

The user account that I set for that "Run whether the user is logged on or not" setting has full admin privileges on the PC.  Checking the box for "Run with highest privileges" doesn't make any difference.  I also have set Pro to have its license "checked out" as offline from AGOL as well.  None of these things seems to have any effect.  The task either runs fine when Task Scheduler is in the "logged on" mode and never runs properly when in the "whether logged in/out" mode.  I'm currently working with Esri Tech Support on this, but they are stumped too.

Pro 3.4.3 Advanced.

0 Kudos
royceSimpson1
Emerging Contributor

I seem to have gotten this one fixed.  In the python script that the task scheduler uses, there are path reference to the network drive where the Pro project lives.  Those references are using our drive letter mappings.  Drive letters do not work when the user is not logged in.  I ended up changing the path string in that py file from the drive letter format to the actual UNC path format.  Now the model automation runs correctly.

0 Kudos
MikeVolz
Frequent Contributor

Yes when running automated scripts, it is best practice to use UNC path format.  This is also a requirement when publishing GIS services from network drives, you need to use the UNC path format.

0 Kudos