Schedule Python script using windows task scheduler

5046
4
Jump to solution
09-23-2019 11:58 AM
RobbieEisenrich
New Contributor III

Howdy,

I modified a script following this blog post Automatically generating assignments in Workforce. The script runs perfectly and I would like to schedule it to run at a specif time each day. To do this I have been following the blog post Scheduling a Python script or model to run at a prescribed time.  I have been attempting this on a VM I created and installed anaconda and python on following this blog Install and set up | ArcGIS for Developers. The script I am running was created on a note book. I then converted this to a .py file to run using task scheduler. The .py file calls for a password to be entered after running the file. I have tested the .py file on the vm by accessing the file through the anaconda prompt and running it from there. However I have had no success with running the script from the Task scheduler.

Can anyone tell me where I am going wrong? #aaron pulver

ACTIONS

Program/Script: C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\python.exe

Add Arguments: "C:\Users\Administrator\Documents\Workforce.py"-password=password

Tags (1)
1 Solution

Accepted Solutions
RobbieEisenrich
New Contributor III

Howdy!

I was able to solve the issue. I killed the VM launched another and went through the steps again. This for some reason worked and I am now able to schedule the script at different intervals.

Thanks guys!

View solution in original post

0 Kudos
4 Replies
MichaelVolz
Esteemed Contributor

Can you try modifying the script where the password is embedded in the script so it does not need to be passed as an argument?  I'm just suggesting this idea to simplify your approach as a trouble-shooting step and not a final solution.

Have you been able to create other python scripts in the past that you run as a Windows Scheduled Task?

What is the operating system of your VM (e.g. Windows Server 2012, Windows Server 2016, etc.)?

RobbieEisenrich
New Contributor III

I have added in the password to the script itself but I am still having no luck. The VM is windows server 2019 base

This is my first time using the windows task scheduler to schedule a python script 

0 Kudos
RobbieEisenrich
New Contributor III

Howdy,

Not sure if this helps but here are screen shots from attempting to run the .py in windows command line vs anaconda command 

As you can see the .py fails in the windows and works in the anaconda prompt. I would run it in the python command line but am unable to find where the python command line is. 

RobbieEisenrich
New Contributor III

Howdy!

I was able to solve the issue. I killed the VM launched another and went through the steps again. This for some reason worked and I am now able to schedule the script at different intervals.

Thanks guys!

0 Kudos