Run Python API script as scheduled task?

10014
35
Jump to solution
04-18-2018 01:38 PM
ShawnHibbs1
New Contributor II

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? 

1 Solution

Accepted Solutions
HildermesJoséMedeirosFilho
New Contributor III

https://github.com/hildermesmedeiros/run-ipynb

I`ve been using that toolbox, for months I did it while ago, you all feel free to use it. But it would not hurt to be a default toolbox, right?

But to do so, it would need more things, it is working for me, so...

ps: My Github project is now public....I`m sorry for that!

View solution in original post

0 Kudos
35 Replies
DanPatterson_Retired
MVP Emeritus

I see nothing in the docs.... https://esri.github.io/arcgis-python-api/apidoc/html/index.html

nor in the sample notebooks https://developers.arcgis.com/python/sample-notebooks/

can the script be run as a general scheduled task?

0 Kudos
RohitSingh2
Esri Contributor

The script can be run as a genera scheduled task using Task Scheduler on Windows and cron on Linux.

You could follow the blog post at https://www.esri.com/arcgis-blog/products/product/analytics/scheduling-a-python-script-or-model-to-r...  for tips on how to do this except that you'd use the Python.exe from the environment that has ArcGIS API for Python installed in it. Refer to Schedule [Virtualenv Dependent] Python Script with Windows Task Scheduler - Super User for how to do this with conda.

ShawnHibbs1
New Contributor II

How do I find the environment where the API is installed?

0 Kudos
JohnYaist1
Esri Contributor

Hi Shawn Hibbs  - Open a command prompt and type:

conda info -e

 This will output a list of all your environments and the path to where they are stored.

You can also search for the arcgis package in a specific environment with the following command:

conda list -n myenv arcgis
PhilipFrancis
New Contributor II

Respectfully folks, please be careful when you are discussing the term environment in such a context. A given user has multiple environment contexts in an OS. As a direct comment to the above statement, conda does not know everything about the user's environment; FURTHERMORE, the environment settings that a user is given at a CLI can be quite different from when run as a task.

0 Kudos
by Anonymous User
Not applicable

Did you find a solution to this? I'm looking for a way to run Jupyter .ipynb file on a daily basis.

0 Kudos
by Anonymous User
Not applicable

How would I schedule my .ipynb to run daily? Do you have an example of how I can achieve this?

0 Kudos
simoxu
by MVP Regular Contributor
MVP Regular Contributor

There's no obvious benefit to run notebook as a backstage task. you can copy all the code into a python script file (.py) then run it in the task scheduler.

by Anonymous User
Not applicable

I have found the only way to download a hosted feature service table with attachments using Python is with the ArcGIS API. This will only work as a .ipynb and not as a .py. I'm aware that I can run .py files on task scheduler but have not found a solution to run a .ipynb on some sort of scheduler.

0 Kudos