Rafal
Rafal

Reputation: 37

Python Script Windows Task Scheduler

This is my first time to schedule a python script. My goal is to schedule my python script to run every 10 min.

MAIN.PY

from scrapy import cmdline
cmdline.execute("scrapy crawl news".split())

I created a task in windows task scheduler, but my script is not running somehow( I know the script is working since i can run it manually ). I been trying to solve this issue for hours without any luck.

First I select my python path, then I select the filepath for the project and choose the .py I want to run. example here Then I choose to trigger every 10 min.

After doing the steps described above, nothing happens. Hope you can help me with a solution to my problem.

Upvotes: 0

Views: 1361

Answers (2)

VinceYang
VinceYang

Reputation: 21

it might be the environment problem.The windows task scheduler is running in C:\Windows\System32 by default,so if your some argument is not absolute path or will changed with the environment,it will get wrong result.i suggest u use some logging way to record your program's running status and result so u can debug where went wrong

Upvotes: 0

Karl Olufsen
Karl Olufsen

Reputation: 186

Not sure that it will fit in your case, but I think it might. Please, check out this topic.

How do you run a Python script as a service in Windows?

Maybe you can run your script as a service and add a simple timer inside the script that launches your routine every 10 minutes from the inside.

Alternative solution that a colleague of mine is using is packing the python script inside an executable by using fbs or pyinstaller and adding it into the task scheduler.

Upvotes: 2

Related Questions