Select to view content in your preferred language

Run Python API script as scheduled task?

11505
35
Jump to solution
04-18-2018 01:38 PM
ShawnHibbs1
Emerging Contributor

I have created a script that updates a feature service through the Python API in Jupyter Notebooks. I was wondering how I can run this as a scheduled task? 

35 Replies
by Anonymous User
Not applicable

Still receiving errors 

0 Kudos
by Anonymous User
Not applicable

I think you're missing a space between "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" and "<your script file.py>"

by Anonymous User
Not applicable

Aaron,

Thanks for all your help on this. I was able to get it to run through Command Prompt and then tested with Windows Task Scheduler. I'm all setup for automating that script now. 

by Anonymous User
Not applicable

I recently moved this script to run weekly on our server using windows task scheduler which deploys a .bat file referencing a .py file but the .zip fgdb files export in ArcOnline in my "Exports" folder but will not download automatically. If I run this script manually or from my local machine it works fine but not on the server. Any recommendations? 

0 Kudos
PhilipFrancis
Emerging Contributor

Hi Rohit, it's noteworthy to add that cron ENV settings are often different from ENV at the CLI when the user is developing the automation script.

0 Kudos
DanPatterson_Retired
MVP Emeritus

We call the Users folder... Users is for Losers because someone wasn't thinking Unicode

p = "C:\Users\dan_p\AppData\Local\ESRI\ArcGISPro"
  File "<ipython-input-1-08bc5c8518ea>", line 1
    p = "C:\Users\dan_p\AppData\Local\ESRI\ArcGISPro"
       ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

# ---- raw encoding or forward slashes your way out

p = r"C:\Users\dan_p\AppData\Local\ESRI\ArcGISPro"
0 Kudos
MichaelVolz
Esteemed Contributor

Dan:

What file is supposed to exist at the location you are referencing?  All I see is subfolders at the location you specify and no python.exe file to execute the py script.

0 Kudos
DanPatterson_Retired
MVP Emeritus

Have you cloned a Pro 2.2.1 environment yet?

One reason why we don't do the clone recommendation if you want to install packages... you have to explain why you have to put double/single quotes around a path to the python executable as well as the script name.  Then the students say.... "but windows allows spaces? don't they?" then I say "sometimes... but not when you need them too"  Teaching is an arduous calling and the root of the expression "just do it"

0 Kudos
MichaelVolz
Esteemed Contributor

I am going to wait until ESRI fixes this issue with a firm release, as I do not want to hack around in the python environment.  Is the location you are specifying (Users) folder, the location where the cloned python environment is placed by default?

0 Kudos
DanPatterson_Retired
MVP Emeritus

Michael... You don't get to choose where you place the clone in a multiuser environment

0 Kudos