Running CRON on Windows

Get help from the community here.

Moderator: Developers

jcasares
Posts: 1
Joined: Fri May 30, 2014 7:22 pm

Running CRON on Windows

Postby jcasares » Fri May 30, 2014 8:48 pm

As I couldn't find anywhere how to do this and is not really trivial, I'm posting here how to do it so others don't have to invest a lot of time:

This is the command to run the scheduled jobs in Windows:

Code: Select all

c:\php\php-win.exe -c c:\path\to\php.ini -f c:\path\to\groupofficecli.php -- -c=c:\path\to\config.php -- -r=core/cron/run -- -q
It is important to add those "--" before a command for groupofficecli.php so they don't get processed by PHP and cause issues.

You just use the Task Sheduler to run this command every 5 minutes and you will see Last Run on System task scheduler filled with the last execution of each scheduled task.

Maybe someone can add it to the Wiki as well.
mschering
Site Admin
Site Admin
Posts: 8292
Joined: Tue Apr 20, 2004 1:06 pm
Location: The Netherlands - Den Bosch
Contact:

Re: Running CRON on Windows

Postby mschering » Tue Jun 03, 2014 7:50 am

Thanks! I'll add it to the wiki.
Best regards,

Merijn Schering
Intermesh
eduardocp25
Posts: 3
Joined: Thu Mar 31, 2016 7:22 pm

Re: Running CRON on Windows

Postby eduardocp25 » Tue May 03, 2016 6:19 pm

Hi, could you please create a guide for a novice, I do not really get properly add the following task in Windows.
Thank you. :roll:
jhsdurham
Posts: 67
Joined: Sun Sep 15, 2013 4:04 am

Re: Running CRON on Windows

Postby jhsdurham » Tue Aug 21, 2018 9:29 pm

Hi,

I know this is an older post but it has important info for Windows server admins. I wanted to add more specific tips that are critical for this to work right.

When you create the Task in Task Scheduler make sure you do the following for settings on the GENERAL tab:
1. Run Whether User is Logged on or not CHECKED
2. Run with Highest Priv CHECKED
3. Configure for : (choose your server version of windows server this is running on)

Under the ACTIONS Tab for the task you need to use:
1: Action: Start a Program
2: Program Script box: c:\php\php-win.exe (or the path to where your PHP directory is)
3: Add Arguments Box: -c c:\php\php.ini -f c:\yourpathto\groupoffice\groupofficecli.php -- -c=C:\yourpathto\groupoffice\config.php -- -r=core/cron/run -- -q
4: Start in box: c:\php\

Under the TRIGGERS tab you set:
1: Begin the task : On Schedule
2: Settings: Daily
3: Advanced Settings: Repeat Task Every (15 minutes) --- or whatever time you want
4: for a duration of : Indefinitely

NO QUOTES around the path names or arguments at all - even if your paths have spaces in the names. This is one odd case where Windows does not want quotes for spaces.

It only takes a few seconds to run and complete the task.
php-win.exe outputs nothing on screen. If you set this up right, you should be able to right-click on the task and choose "Run" to test it manually. Refresh your task list and it should show (0x0) for the result within just a few seconds. That means it ran correctly, and if you go to your "Manage System Tasks" tab in Group Office under your Admin login you will now see the list of times that all the cron job tasks just ran at/completed.

If you get (0x1) something is still wrong in your path (item #2 or item #3). This does work.
jamesnw
Posts: 5
Joined: Sat Sep 26, 2009 2:54 am

Re: Running CRON on Windows

Postby jamesnw » Tue Feb 05, 2019 4:56 am

I found this does not work on my Windows 2012 R2 server (I just get error code 0x1 no matter what I do). In fact, after installing a fresh copy of the most recent version I got a popup in the tasks view that said this:

Code: Select all

php C:\inetpub\wwwroot\...website...\cron.php C:\inetpub\wwwroot\...website...\config.php
Created a new task, using mostly the same procedure as jhsdurham posted, with these modifications:

In the "Program/script" box put the path to where `php.exe` is installed (NOT php-win).
In the "Start in" box, put the path to where `php.exe` is installed (without the php.exe filename of course).
For "Add arguments", put this: C:\inetpub\wwwroot\...website...\cron.php C:\inetpub\wwwroot\...website...\config.php

Who is online

Users browsing this forum: No registered users and 3 guests