Select to view content in your preferred language

Python 3.x Scheduled Task Fails

7112
11
06-29-2017 09:33 AM
mpboyle
Frequent Contributor

I am in the process of migrating a scheduled task from ArcMap to ArcGIS Pro that exports maps to PDFs on a daily basis.  I have the python script written, and it executes as expected when running through an IDE (PyCharm) using the python executable delivered with ArcGIS Pro (..\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe).

When I try executing the same script through Windows Task Scheduler, I can tell the script is running because a .txt file is generated to log processes, however, at some point the script is failing as the maps are not being exported.  The task scheduler returns a code of 0xFFFFFFFF and I haven't found anything of substance for this code.  There are no warnings or errors in the task history either to give any clues.

We have several other tasks that are running just fine using python 2.7 along with ArcMap/ArcGIS Desktop using my domain account, so the username I'm using has sufficient permissions to execute a task.

I also have ArcGIS Pro setup to login automatically, which again, works fine through the IDE.  I tried using a Single Use license, with the same result.

If I comment out all the ArcGIS Pro / arcpy functions, the script will execute as expected through Task Scheduler (creates a log, and sends an email).  It seems to be specific to the arcpy functions.

Is anyone running a Windows Task Scheduler task using ArcGIS Pro projects successfully?  If so, am I missing something?  Is there some sort of permission setting I'm missing?  Any ideas of where to look...?

11 Replies
Arne_Gelfert
Frequent Contributor

Assuming the original question was address a while back. So Daryl Hochhalter‌ ...

I've run into various issues with this but ultimately got it working and now have scheduled tasked for arcpy jobs running on Win Server. Typically I have found:

  • Use a service account to run the job.
  • Make sure service account has logon as service privileges.
  • Make sure the service account get can a Pro license (named or concurrent, depending on your version of Pro)
  • Start up ArcGIS Pro at least once using the service account to set up that account's environment.
  • Make sure you can import arcpy when running the script manually.
  • Make sure you're Python path is correct or you put in the whole path to the conda Python install in any batch files that gets executed in task scheduler.
  • Don't forget about this process when you upgrade/change license servers or make Portal changes.
SolanaFoo2
Regular Contributor

How do you "make sure the service account can get a Pro license"?  How do you configure that?  We have named user licenses tied to our AGOL organization.

0 Kudos