285

A Google search turned up software that performs the same functions as cron, but nothing built into Windows.

I'm running Windows XP Professional, but advice for any version of Windows would be potentially helpful to someone.

Is there also a way to invoke this feature (which based on answers is called the Task Scheduler) programatically or via the command line?

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Thomas Owens
  • 107,741
  • 94
  • 299
  • 427
  • 5
    What feature of `cron` do you need that Task Scheduler doesn't provide? – Chris Jester-Young Sep 25 '08 at 12:24
  • 2
    Cron emails stdout and stderr to the user -- how do we do that in Task Scheduler? – user3450049 Feb 28 '18 at 14:40
  • @user3450049: You allway can add a task in actions section to send logs by mail. You can use from a Telnet o Sendmail as fit your convenience. See https://stackoverflow.com/questions/18652001/send-mail-via-cmd-console – 0zkr PM Jul 10 '19 at 16:45

15 Answers15

299

For the original question, asking about Windows XP (and Windows 7): Windows Task Scheduler

For command-line usage, you can schedule with the AT command.

For newer Microsoft OS versions, Windows Server 2012 / Windows 8, look at the schtasks command line utility.
If using PowerShell, the Scheduled Tasks Cmdlets in Windows PowerShell are made for scripting.

Kris Kumler
  • 6,157
  • 3
  • 21
  • 27
  • 13
    In Windows 10 `at.exe` is deprecated and won't run. `schtasks.exe` is difficult to use (e.g. won't run without admin privileges) and bugged (e.g. the `/Z` switch). – Vlastimil Ovčáčík Nov 19 '15 at 11:37
  • what about windows 7? – Tarik Dec 13 '15 at 18:29
  • @Tarik Windows 7 will support the Task Scheduler as well. – Kris Kumler Dec 14 '15 at 16:47
  • My windows 7 cmd has AT and schtasks. Is there a difference/preference? Why have both? – jiggunjer Aug 03 '16 at 01:39
  • On Windows 7, AT will be for one-time tasks to run; schtasks would be used for repeating tasks. – Kris Kumler Aug 05 '16 at 00:20
  • 8
    The Task Scheduler is such a dumpster fire of a piece of sofware. Everytime I open it there's a 50/50 chance it'll drop the framerate for the entire computer down to 3fps while trying to load a table view of like 6 items – Mattwmaster58 Apr 14 '18 at 05:50
  • lol, @MattM. If using XP still for things, there might be a bigger problem! – Kris Kumler Apr 18 '18 at 15:47
  • @KrisKumler The Windows Task Scheduler is shipped from version XP - 10. Sometimes it's easier just to click a few buttons than fiddle with a CLI. (of course, in the case of the task scheduler, it's definitely worth it to fiddle with the CLI) – Mattwmaster58 Apr 18 '18 at 23:07
  • The ScheduledTask Cmdlets API involves `CimInstance` here and there. It's very difficult to work with, because `CimInstance` does not provide any type information. For example, I want to know more details about the `-Action` parameter in [`Register-ScheduledTask`](https://docs.microsoft.com/en-us/powershell/module/scheduledtasks/register-scheduledtask). – Franklin Yu Nov 20 '18 at 21:21
28

The Windows "AT" command is very similar to cron. It is available through the command line.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
stephenbayer
  • 11,718
  • 15
  • 59
  • 98
10

Use the Windows Task Scheduler to schedule tasks over time and dates.

Martijn Pieters
  • 889,049
  • 245
  • 3,507
  • 2,997
Dror Helper
  • 28,989
  • 15
  • 76
  • 129
10

The 'at' command.

"The AT command schedules commands and programs to run on a computer at a specified time and date. The Schedule service must be running to use the AT command."

leppie
  • 109,129
  • 16
  • 185
  • 292
10

pycron is close match on Windows. The following entries are supported:

1    Minute (0-59)
2    Hour (2-24)
3    Day of month (1-31)
4    Month (1-12, Jan, Feb, etc)
5    Day of week (0-6) 0 = Sunday, 1 = Monday etc or Sun, Mon, etc)
6    User that the command will run as
7    Command to execute
iliketocode
  • 6,652
  • 4
  • 41
  • 57
user816347
  • 117
  • 1
  • 2
8

Zcron is available free for personal use.

Brian Burns
  • 14,953
  • 5
  • 69
  • 59
Zsolt Botykai
  • 46,263
  • 14
  • 81
  • 102
7

The closest equivalent are the Windows Scheduled Tasks (Control Panel -> Scheduled Tasks), though they are a far, far cry from cron.

The biggest difference (to me) is that they require a user to be logged into the Windows box, and a user account (with password and all), which makes things a nightmare if your local security policy requires password changes periodically. I also think it is less flexible than cron as far as setting intervals for items to run.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
ckramer
  • 9,285
  • 1
  • 21
  • 38
  • 2
    While cron is definitely superior to Windows tasks, you can actually use the computers 'SYSTEM' account which doesn't require a password and has full permissions to the local computer. Though this obviously has issues if you utilize external resources (such as a shared drive that requires domain creds). – Steve Bauman Apr 06 '17 at 03:13
  • @SteveBauman The key is LOCAL RESOURCES, Windows might have the best task scheduler ever but if those task can only work on local resources it is 100% useless if you need to do something as simple as copy a backup to the local PC on a schedule. – krowe2 Feb 13 '18 at 20:02
7

Is there also a way to invoke this feature (which based on answers is called the Task Scheduler) programatically [...]?

Task scheduler API on MSDN.

Adam Mitz
  • 5,922
  • 1
  • 25
  • 28
6

If you prefer good ol' cron, CRONw is the way to go.

Supported systems

* Windows 2000 (any version)    works
* Windows XP (SP 2)             works
* Windows Server 2003           works
* Windows NT 4 (SP 6)           should work but not tested
* Windows 3.11, Windows 95,
  Windows 98, Windows ME,
  Windows XP beneath SP2        not supported by design
enobrev
  • 21,288
  • 6
  • 40
  • 53
  • 1
    I tried this one, and when I finally installed it and tried to test it, all I got was this message: `We were asked to go - so I'm out finally...` Any command I tried sent me that message. WTF? Is this project not active anymore or what's the meaning of that message?? THANKS – Metafaniel Mar 09 '15 at 19:08
  • 1
    @Metafaniel, I haven't had a Windows system in about 4 or 5 years, so I haven't really kept up. Googling that response only leads me to this page and I don't see anything on their site about shutting down. Looking at the [sourceforge repo](http://sourceforge.net/projects/cronw/files), it looks like it hasn't changed in about a decade, so I'm wondering if maybe there's some sort of conflict on your local system? Considering it's been that long since the last update, I would definitely say it's no longer active, though that is a really strange response. – enobrev Mar 10 '15 at 20:39
  • 1
    @Metafaniel I also downloaded and grepped the codebase for that message and found nothing. Good luck figuring out what's going on! – enobrev Mar 10 '15 at 20:40
  • 1
    @Metafaniel As mentioned in the post, for Windows beyond XP SP2 it is not supported. – LoMaPh Dec 07 '18 at 22:42
6

Not exactly a Windows version, however you can use Cygwin's crontab. For install instructions, see here: here.

Przemek Kryger
  • 677
  • 4
  • 9
  • 3
    This answer contains linkrot, but the StackOverflow question [How do you run a crontab in Cygwin on Windows?](http://stackoverflow.com/questions/707184/how-do-you-run-a-crontab-in-cygwin-on-windows) is helpful. – Michael Scheper Apr 26 '13 at 02:06
5

There is NNCron for Windows. IT can schedule jobs to be run periodically.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
shasi kanth
  • 6,503
  • 22
  • 101
  • 151
2

In addition to Windows Task Scheduler you also have 'at' on Windows. I'm not sure how it differs from Task Scheduler besides the fact that it has a command line interface.

jm4
  • 188
  • 1
  • 3
1

The At command is now deprecated

you can use the SCHTASKS

Saher Ahwal
  • 8,230
  • 28
  • 75
  • 136
1
  1. You can use the Scheduled-Tasks API in PowerShell along with a config.json file for parameters input. I guess the minimum limitation is 5 minutes. A sample tutorial for very basic Schedule Tasks creation via APIs

  2. You can use the schtasks.exe via cmd too. I could see the minute modifier limitation to 1 minute on executing schtasks.exe /Create /?. Anyways AT is now deprecated.

enter image description here

Anyways, I am working on a tool to behave like CRON. I will update here if it is successfull.

Pikesh Prasoon
  • 179
  • 1
  • 7
1

Check out the excellent Cronical program at https://github.com/mgefvert/Cronical

It is a .NET program that reads a text file with unix-like cron lines. Very convenient to use. It will send emails if stdout just like unix cron. It even supports acting as the service runner.

Cominvent
  • 101
  • 3