0

I am using Anaconda base environment. I am trying to schedule a task to run python script, using windows task scheduler. The script sends an email to me -

Following is the task scheduler configuration -

Program/script: cmd

Add arguments(optional): "/c conda.bat activate && python myscript.py && deactivate"

When I run this in command prompt as "cmd "/c conda.bat activate && python myscript.py && deactivate", it works fine and I do receive the email as expected. When I run from the task scheduler, it shows Action completed/Task completed etc. No errors in task scheduler, but I don't receive an email. I can't figure out, what really happens when I run the task scheduler. Please let me know if there is anyway to schedule this script that sends email.

Limitations: I am not the admin of the machine and the policy does not allow me to run .bat files

--------------

Update I found an alternative and might be very specific to limitations in my environment. I am able to execute my script using powershell, so I went with that approach and am able to schedule the script. It's likely that group policy/privileges had something to do with, why I was not able to get scheduler to work with previous approach. For using anaconda base environment in powershell, I referenced following topic -

How to activate different anaconda environment from powershell

AMC
  • 2,642
  • 7
  • 13
  • 35
Yogi
  • 38
  • 6
  • 1
    What is the current working directory when you run the command by hand, and what is the current directory when it is run from the task scheduler? – John Gordon Dec 14 '20 at 00:49
  • When I run from the command prompt - it is my user directory "C:\Users\yogi" When I run from task scheduler, I am guessing the directory of task scheduler, which happens to be "C:\Windows\SysWOW64" – Yogi Dec 14 '20 at 01:14
  • John, I changed the working directory in command prompt to "C:\Windows\SysWOW64" and I updated the script path in command prompt and task scheduler as - cmd "/c conda.bat activate && python c:\Users\yogi\myscript.py && deactivate" and made the same modification in scheduler, still command prompt works but not the scheduler – Yogi Dec 14 '20 at 01:33
  • 2
    Does this answer your question? [Schedule a script developed in Anaconda via Windows Task Scheduler](https://stackoverflow.com/questions/49542912/schedule-a-script-developed-in-anaconda-via-windows-task-scheduler) – AMC Dec 19 '20 at 01:16
  • There seem to already be a few questions on the subject. – AMC Dec 19 '20 at 01:16

0 Answers0