Select to view content in your preferred language

Log into ArcGIS Pro through a script

1018
8
03-05-2024 11:20 AM
LondonWalker
Regular Contributor

Due to our server settings, our arcpro logs us out every time we log out of the computer. This makes it impossible to schedule arcpy tasks in task scheduler. Is there a way to log in remotely without needing arcpy since we need to log in to initialize it?

8 Replies
clt_cabq
Frequent Contributor

you should be able to set up a python script to run through windows task scheduler on your server. I did this for about 20+ scripts that ran on a server on schedules ranging from every few minutes to hourly, daily and weekly. I'll dig around and see if i have any additional details I can share with you, its been a while since i fussed with this. Hopefully someone doing this more recently will chime in.

Here are a couple of links that might help, one is a couple of years old, the other a bit more recent.

schedule a python script with windows task manager 

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

In the last one scroll to the bottom and read the section on running python outside of Pro

 

LondonWalker
Regular Contributor

Thank you for these, I will look over them. We are just particularly struggling with getting one service account to run them. Others work fine.

0 Kudos
DonMorrison1
Frequent Contributor

This might also be useful 

https://community.esri.com/t5/python-questions/best-practices-document-for-setting-up-automated/m-p/...

I've  found the it is best to run the scheduled program under a Single Use License

RhettZufelt
MVP Notable Contributor

I installed Pro on the server machine,  logged onto the server machine with the service account, logged into Pro with appropriate user, and select the Sign in automatically option.  This stores the credential so that it automatically logs me in with the last used credentials.

The scheduled tasks will then also use this last logged in credentials to run the python script(s).  However, there is a time out on this, I believe it is two weeks.  So, if it's been too long since the appropriate user has logged onto Pro manually (or if a different user has logged on in between), it will fail.  (So, we don't allow 'other' users to run Pro on the server machine)

My workaround for this is to run a scheduled task every week that opens Pro, pauses a few seconds, then closes Pro.  This keeps the credentials up to date and keeps my scheduled tasks running. 

RhettZufelt_2-1709915830266.png

R_

 

LondonWalker
Regular Contributor

Yeah I've seen this as a possibly, ours just logs out right away so I don't have the option to open it back up and it still be logged in.

0 Kudos
RhettZufelt
MVP Notable Contributor

I don't 'log out', just close Pro.

As long as the Sign in automatically was checked last login, and didn't log out, it works.

Do you not see the Sign in automatically checkbox?

R_

0 Kudos
LondonWalker
Regular Contributor

Yes, we have clicked that checkbox. It does not stay signed in. On my desktop if I close out of pro and reopen I am still logged in. It doesn't work on my server machine, no matter if the checkbox is checked

0 Kudos
RhettZufelt
MVP Notable Contributor

That's too bad.  Not sure if it is a setting on your Server, Domain or something else.

The only 'servers' I have tested this on is Windows Server 2016 Datacenter, and Window Server 2019 Datacenter.  Has been working on both for a couple years now.

R_

0 Kudos