Python Forum
Batch file not running python script in task scheduler - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Batch file not running python script in task scheduler (/thread-18177.html)



Batch file not running python script in task scheduler - davork - May-08-2019

I have a scrapping python script and a batch file that when run from CMD works perfectly however when I try to run it from Task Scheduler nothing happens.

Don't know if this is relevant but script would open Firefox and scrape some websites.

Have tried adding full permissions to the folders and files that I am using. Also, have tried in Task Scheduler to set up "Run whatever user is logged on or not", "Run with highest privileges" , "Start in (optional): add/bactch/file/path" and so on

Batch file:

py "C:\python_test\myscript.py"


It should run the python script which opens Firefox and scrapes some websites, gets their links and saves them in a csv file

Batch file is in the folder where script is so C:\python_test\batch.bat... if I run this batch file from CMD or by double clicking on it it runs perfectly and executes the script successfully


RE: Batch file not running python script in task scheduler - Gribouillis - May-08-2019

Have you tried to log some information to a file from myscript.py when it runs?


RE: Batch file not running python script in task scheduler - davork - May-09-2019

@Gribouillis could you explain a bit better what exactly do you mean?
Thanks


RE: Batch file not running python script in task scheduler - Gribouillis - May-09-2019

davork Wrote:@Gribouillis could you explain a bit better what exactly do you mean?
I mean add this in the script's file
import logging
logging.basicConfig(filename='example.log',level=logging.DEBUG)

logging.debug('myscript.py starting.')
...
logging.debug('We reached this point')
...
logging.debug('myscript.py exiting')
Then examine the contents of the file example.log after the script's execution.