Python Forum

Full Version: Batch file not running python script in task scheduler
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
Have you tried to log some information to a file from myscript.py when it runs?
@Gribouillis could you explain a bit better what exactly do you mean?
Thanks
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.