0

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.

Rafal
  • 37
  • 1
  • 11

2 Answers2

2

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.

Karl Olufsen
  • 186
  • 1
  • 10
  • I will check alternative solution after, but first I want to figure out how to deal with Windows Task Scheduler and .py I been searching online and most guides show the same and thats why I cant understand why it is not running my script. – Rafal Apr 06 '20 at 12:53
  • I will give your alternative a try. Looking at pyinstaller now. – Rafal Apr 06 '20 at 13:53
0

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

VinceYang
  • 21
  • 3
  • Yes, but C:\Windows\System32\Tasks is a Task storage. Each Task will have its individual location added in Actions: New: Program/Script – Alien_Explorer Apr 01 '21 at 09:52