简体   繁体   中英

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM