Running a scheduled task on a server machine

2615
2
07-16-2019 07:57 AM
annegrimes2
New Contributor II

Hello,

I need to run a python 3.x script that uses ArcGIS Pro arcpy as a weekly scheduled task on a server machine. Our organization uses named user licenses managed via ArcGIS Online. I configured ArcGIS Pro to work offline on the Server.  However I cannot run the task with my ArcGIS Pro Userid. I have to use a designated account which has access to all the servers.  How can I get my arcpy script to execute as a scheduled task on the server?

2 Replies
MichaelVolz
Esteemed Contributor

Did you have the same weekly scheduled task setup for ArcMap 10.x with a concurrent use license?  If so, would you be able to at least convert 1 Named User account to a concurrent use license?

ThomasColson
MVP Frequent Contributor

In order for the task to run (when you're logged off) you need to right-click on Pro, run as different user, use the logon for the service account running the task, log that service account into AGOL (Portals). This is significantly different than how to run a schedule python task in the ArcMap world, which only required a headless account baked into the py script to be able to interact with AGOL, and one I hope ESRI changes soon, as this hokey workaround is not sustainable. 

https://community.esri.com/thread/221292-python-script-as-sheduled-task-arcgis-pro

https://community.esri.com/thread/197493-python-3x-scheduled-task-fails

From https://pro.arcgis.com/en/pro-app/arcpy/get-started/installing-python-for-arcgis-pro.htm

Authorizing Python outside the application

If you run Python scripts that use ArcGIS Pro functionality outside of the ArcGIS Pro application, such as a Python IDE, from a command prompt, or running scripts through scheduled tasks, one of the following conditions must be true:

  • Sign me in automatically is checked when signing in to ArcGIS Pro.
  • ArcGIS Pro is currently open.
  • ArcGIS Pro has been authorized to work offline.

is false, as, in meeting "ArcGIS Pro has been authorized to work offline." and "Sign me in automatically is checked when signing in to ArcGIS Pro.", the scheduled task fails unless Pro is "ArcGIS Pro is currently open.", which means all three conditions must be met, not just one.