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".
我在机器上四处寻找并发现了“计划任务”控制面板,但它似乎与运行脚本没有任何关系,据我所知,“向导”提供的选项。
4 个解决方案
#1
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脚本宿主。我确信红宝石有类似的东西。
#2
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解释器,并添加脚本的名称作为参数运行)。
#3
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小时左右。
#4
The 'at' command is a nice command line version of a scheduler.
'at'命令是调度程序的一个很好的命令行版本。
#1
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脚本宿主。我确信红宝石有类似的东西。
#2
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解释器,并添加脚本的名称作为参数运行)。
#3
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小时左右。
#4
The 'at' command is a nice command line version of a scheduler.
'at'命令是调度程序的一个很好的命令行版本。