在 Windows 中设置 cron 作业
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7195503/
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
Setting up a cron job in Windows
提问by mona
I have to download a file from an SFTP server everyday. I have the program which retrieves the file from the server but I was thinking of setting up a cron job (or anything similar) to automate that. We are a Windows shop and need to set up the cron job in Windows.
我必须每天从 SFTP 服务器下载文件。我有从服务器检索文件的程序,但我正在考虑设置一个 cron 作业(或任何类似的东西)来自动化它。我们是一家 Windows 商店,需要在 Windows 中设置 cron 作业。
回答by steenhulthin
The windows equivalent to a cron job is a scheduled task.
相当于 cron 作业的窗口是计划任务。
A scheduled task can be created as described by Alexand Rudu, but it can also be done command line with schtasks
(if you for instance need to script it or add it to version control).
可以按照Alex和Rudu 的描述创建计划任务,但也可以使用命令行完成schtasks
(例如,如果您需要编写脚本或将其添加到版本控制中)。
An example:
一个例子:
schtasks /create /tn calculate /tr calc /sc weekly /d MON /st 06:05 /ru "System"
Creates the task calculate, which starts the calculator(calc) every monday at 6:05 (should you ever need that.)
创建任务计算,它会在每个星期一的 6:05 启动计算器(计算)(如果你需要的话。)
All available commands can be found here: http://technet.microsoft.com/en-us/library/cc772785%28WS.10%29.aspx
所有可用的命令都可以在这里找到:http: //technet.microsoft.com/en-us/library/cc772785%28WS.10%29.aspx
It works on windows server 2008 as well as windows server 2003.
它适用于 windows server 2008 以及 windows server 2003。
回答by s-hunter
- Make sure you logged on as an administratoror you have the same access as an administrator.
- Start->Control Panel->System and Security->Administrative Tools->Task Scheduler
- Action->Create Basic Task->Type a name and Click Next
- Follow through the wizard.
- 确保您以管理员身份登录或您具有与管理员相同的访问权限。
- 开始->控制面板->系统和安全->管理工具->任务计划程序
- 操作->创建基本任务-> 键入名称并单击下一步
- 按照向导进行操作。
回答by Alex
http://windows.microsoft.com/en-US/windows7/schedule-a-task
http://windows.microsoft.com/en-US/windows7/schedule-a-task
maybe that will help with windows scheduled tasks ...
也许这将有助于 Windows 计划任务......
回答by Rudu
回答by Josh Correia
If you don't want to use Scheduled Tasksyou can use the Windows Subsystem for Linuxwhich will allow you to use cron jobs like on Linux.
如果您不想使用计划任务,您可以使用适用于 Linux的Windows 子系统,它允许您像在 Linux 上一样使用 cron 作业。
To make sure cron is actually running you can type service cron status
from within the Linux terminal. If it isn't currently running then type service cron start
and you should be good to go.
要确保 cron 确实在运行,您可以service cron status
在 Linux 终端中输入。如果它当前没有运行,那么输入service cron start
你应该很高兴。