安排 Python 脚本 - Windows 7 [英] Schedule Python Script - Windows 7
问题描述
我有一个 python 脚本,我想定期运行它.我正在运行 Windows 7.实现此目的的最佳方法是什么?最简单的方法?
I have a python script which I would like to run at regular intervals. I am running windows 7. What is the best way to accomplish this? Easiest way?
推荐答案
可以在命令行中进行如下操作:
You can do it in the command line as follows:
schtasks /Create /SC HOURLY /TN PythonTask /TR "PATH_TO_PYTHON_EXE PATH_TO_PYTHON_SCRIPT"
这将创建一个名为PythonTask"的每小时任务.您可以将 HOURLY 替换为 DAILY、WEEKLY 等.PATH_TO_PYTHON_EXE 将类似于:C:\python25\python.exe.通过在命令行中编写此内容来查看更多示例:
That will create an hourly task called 'PythonTask'. You can replace HOURLY with DAILY, WEEKLY etc. PATH_TO_PYTHON_EXE will be something like: C:\python25\python.exe. Check out more examples by writing this in the command line:
schtasks /?
否则,您可以打开任务计划程序并通过 GUI 执行此操作.希望这会有所帮助.
Otherwise you can open the Task Scheduler and do it through the GUI. Hope this helps.
这篇关于安排 Python 脚本 - Windows 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!