如何将 Rake 任务作为 Windows“计划任务"运行? [英] How can I run a Rake task as a Windows "scheduled task"?
问题描述
我有一个 rake 任务,需要在 Windows XP 机器上作为日常工作运行.我发现了 Windows 的计划任务"控制面板.我想弄清楚如何让它运行我的 Rake 任务.
I have a rake task I need to run as a daily job on a Windows XP machine. I discovered the Windows "scheduled tasks" control panel. I'm trying to figure out how to get it to run my Rake task.
其中两个字段是运行"(带有浏览按钮)和开始于".我尝试将 rake mycategory:mytask
输入run",并将包含 Rake 任务的 Rails 项目目录输入start in".结果是一条消息说任务无法启动".
Two of the fields are "run" (with a browse button) and "start in". I tried to enter rake mycategory:mytask
into "run" and my Rails project dir containing the Rake task into "start in". The result was a message saying the task "could not start".
如何设置 Windows计划任务"来运行 Rake 任务?
How can I get set up a Windows "scheduled task" to run a Rake task?
推荐答案
如果您可以构建一个可以正确执行的批处理文件,我会这样做,然后您就可以将批处理文件与任务一起运行.
If you can build a batch file that can execute it properly I would do so, and then you can direct the batch file to run with the task.
>
这样的事情应该可以工作:
Something like this should work:
:: Run task every hour
@call rake stats RAILS_ENV="production"
这篇关于如何将 Rake 任务作为 Windows“计划任务"运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!