What is the Windows version of cron? [closed]
Asked Answered
C

15

297

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?

Conformity answered 25/9, 2008 at 12:23 Comment(3)
What feature of cron do you need that Task Scheduler doesn't provide?Amimia
Cron emails stdout and stderr to the user -- how do we do that in Task Scheduler?Idonna
@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://mcmap.net/q/101956/-send-mail-via-cmd-consoleCaliper
C
308

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.

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

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

Cysticercus answered 25/9, 2008 at 12:24 Comment(9)
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).Nether
what about windows 7?Seiler
@Seiler Windows 7 will support the Task Scheduler as well.Cysticercus
My windows 7 cmd has AT and schtasks. Is there a difference/preference? Why have both?Hemipterous
On Windows 7, AT will be for one-time tasks to run; schtasks would be used for repeating tasks.Cysticercus
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 itemsUnstuck
lol, @MattM. If using XP still for things, there might be a bigger problem!Cysticercus
@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)Unstuck
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.Osana
G
28

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

Gummite answered 25/9, 2008 at 12:26 Comment(2)
The link that you provided also directed me to the SCHTASKS command.Conformity
The at command was deprecated in windows 8 -- lifewire.com/at-command-2618090Ronironica
I
12

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

Infiltration answered 25/9, 2008 at 12:25 Comment(0)
L
11

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
Longwinded answered 26/6, 2011 at 17:32 Comment(2)
This is not a conmmand-line tools. As I see, it only check if current time match your settings.Dov
This is merely a parser, it does not execute the tasks.Replevin
W
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."

Wideeyed answered 25/9, 2008 at 12:26 Comment(1)
depreciated, use schtasks.exe.Lovins
M
8

Zcron is available free for personal use.

Mikkanen answered 25/9, 2008 at 12:55 Comment(2)
Z-Cron excactly.Rule
it only allows cronjobs with 5 minutes interval.Idolatrous
V
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.

Valuable answered 25/9, 2008 at 12:28 Comment(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).Kathikathiawar
@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.Abattoir
C
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.

Cazzie answered 25/9, 2008 at 12:30 Comment(0)
M
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
Monck answered 25/9, 2008 at 12:38 Comment(4)
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?? THANKSPaisley
@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, 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.Monck
@Paisley I also downloaded and grepped the codebase for that message and found nothing. Good luck figuring out what's going on!Monck
@Paisley As mentioned in the post, for Windows beyond XP SP2 it is not supported.Popcorn
E
6

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

Easterly answered 23/6, 2011 at 8:39 Comment(1)
This answer contains linkrot, but the StackOverflow question How do you run a crontab in Cygwin on Windows? is helpful.Overreach
U
6

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

Ushijima answered 10/9, 2012 at 4:51 Comment(0)
E
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.

Endure answered 25/9, 2008 at 12:27 Comment(0)
C
2

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.

Claro answered 9/11, 2018 at 12:51 Comment(0)
P
1

The At command is now deprecated

you can use the SCHTASKS

Phenomenon answered 16/10, 2015 at 22:15 Comment(0)
O
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.

Obbard answered 16/8, 2018 at 18:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.