Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up a cron job in Windows

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.

like image 277
mona Avatar asked Aug 25 '11 18:08

mona


People also ask

How do I setup a cron job in Windows?

- Go to Start >> Control Panel >> Scheduled Tasks >> Add Scheduled Task. - Type "Moodle Cron" as the name of the task and select "Daily" as the schedule. Click "Next". - Select "12:00 AM" as the start time, perform the task "Every Day" and choose today's date as the starting date.

How do I setup a cron job in Windows 10?

First, in the main window of the Task Scheduler, scroll down until you see your task name. If you used the name “cron,” it should be found toward the top of the list. Right-click the task and select “Run.” Then, go back to your WSL terminal and type in sudo service cron status , and it should say that cron is running.

Can you use cron job on Windows?

On Microsoft Windows, cron jobs are known as Scheduled Tasks. They can be added through the Windows Task Scheduler user interface, by using PowerShell or with help of schtasks.exe . Running a task at specific time or at recurring dates is one of the common administrative tasks on all operating systems.


2 Answers

The windows equivalent to a cron job is a scheduled task.

A scheduled task can be created as described by Alex and 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).

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.)

All available commands can be found here: http://technet.microsoft.com/en-us/library/cc772785%28WS.10%29.aspx

It works on windows server 2008 as well as windows server 2003.

like image 169
steenhulthin Avatar answered Sep 19 '22 14:09

steenhulthin


  1. Make sure you logged on as an administrator or you have the same access as an administrator.
  2. Start->Control Panel->System and Security->Administrative Tools->Task Scheduler
  3. Action->Create Basic Task->Type a name and Click Next
  4. Follow through the wizard.
like image 25
s-hunter Avatar answered Sep 20 '22 14:09

s-hunter