每10秒运行一次Python脚本[关闭](Run Python script every 10 seconds [closed])
我有一个功能来做一些工作。 代码应重复1.3亿次。
目前,我使用Crontab每1分钟运行一次python脚本。 它需要很长时间,我希望这个python脚本在第一次运行时运行,并在工作结束之前不断重复。 我想在2个任务之间休息10秒。 我怎样才能做到这一点?
I have a function to do some work. The code should repeat 130 million times.
Currently, I use Crontab to run a python script every 1 min. It takes too long a time, I want that this python script run when I run it the first time and keep repeating continuously until the work gets over. I want a 10 seconds break between 2 task. How can I do that?
最满意答案
尝试计划模块
import schedule import time def job(): print("I'm working...") schedule.every(10).minutes.do(job) schedule.every().hour.do(job) schedule.every().day.at("10:30").do(job) while 1: schedule.run_pending() time.sleep(1)只需运行: pip install schedule
Try the schedule module
import schedule import time def job(): print("I'm working...") schedule.every(10).minutes.do(job) schedule.every().hour.do(job) schedule.every().day.at("10:30").do(job) while 1: schedule.run_pending() time.sleep(1)Just run : pip install schedule
更多推荐
发布评论