您如何安排在 Windows XP 上运行的每日脚本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/445138/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:49:23  来源:igfitidea点击:

How do you schedule a daily script run on Windows XP?

windowsrubywindows-xpcronscheduled-tasks

提问by Ethan

I wrote a script in Ruby. I'd like to run it every day at a certain time. How do you do that on a Windows XP system?

我用Ruby写了一个脚本。我想每天在特定时间运行它。你如何在 Windows XP 系统上做到这一点?

I poked around on the machine and discovered the "scheduled tasks" control panel, but it doesn't seem to have anything to do with running scripts, as far as I can tell from the options offered by the "wizard".

我在机器上闲逛并发现了“计划任务”控制面板,但据我从“向导”提供的选项中可以看出,它似乎与运行脚本没有任何关系。

回答by scottm

Scheduled Tasks. Sometimes, you have to make a batch file call the script, and schedule the batch.

计划任务。有时,您必须使批处理文件调用脚本,并安排批处理。

say you have "script.vbs" you want to run, you will have to create this batch:

假设您有要运行的“script.vbs”,则必须创建此批处理:

cscript script.vbs

cscript is the windows script host which interprets the vbs script. I'm sure ruby has something similar.

cscript 是解释 vbs 脚本的 windows 脚本宿主。我确定 ruby​​ 有类似的东西。

回答by frankodwyer

You can do it with scheduled tasks, just browse for the program or script you want to run if it isn't listed (in this case, the ruby interpreter I guess, and add the name of the script to run as an argument).

您可以使用计划任务执行此操作,只需浏览要运行的程序或脚本(如果未列出)(在本例中,我猜是 ruby​​ 解释器,并添加要运行的脚本名称作为参数)。

回答by Brettski

Use the Windows task scheduler.

使用 Windows 任务计划程序。

Under Control Panel > Schedule Tasks.

在控制面板 > 计划任务下。

You can set it up to run any application or file executable from the command line.

您可以将其设置为从命令行运行任何应用程序或可执行文件。

Update:(1/15/09)A good point from Wouter van Nifterick, remember to take care that the process finishes before the next one runs (in comments).

更新:(1/15/09) Wouter van Nifterick 的一个好点,记住要注意该过程在下一个运行之前完成(在评论中)。

This can be done by going into the advanced options and adjust the allowed amount of time the task may run. If the task is already configured open it and click the Settings tab. At the top of this tab you will see a checkbox followed by 'Stop the task if it runs for:' then there are two text boxes to enter hours and minutes. If your script runs once a day you will want this set to 23 hours or so.

这可以通过进入高级选项并调整任务可能运行的允许时间来完成。如果已配置任务,请打开它并单击设置选项卡。在此选项卡的顶部,您将看到一个复选框,后跟“如果任务运行时停止任务:”,则有两个文本框可以输入小时和分钟。如果您的脚本每天运行一次,您将希望将其设置为 23 小时左右。

回答by Nathan

The 'at' command is a nice command line version of a scheduler.

'at' 命令是调度程序的一个很好的命令行版本。