Forums / Developer / Problem Running Cron in Windows

Problem Running Cron in Windows

Author Message

Fraser Hore

Wednesday 28 July 2010 5:46:34 pm

I have a local instance of ez on my windows laptop and I'm trying to get runcronjobs.php to run. I've put the following into a batch file:

SET PATH="C:\Users\xxx\UniServer\usr\local\php";
start php.exe runcronjobs.php -d -s issat_site ezfindexcontent

and put the batch file in the same directory as runcronjobs.php.

I'm getting a lot of errors that variables aren't set.

Any suggestions?

Thanks!

Robin Muilwijk

Thursday 29 July 2010 12:02:36 am

Hi Fraser,

What if you try that command from a commandline box first? Does that work? And there isn't any subfolder in ..\local\php right? I had another php5.2.x folder in there myself.

Regards Robin

Board member, eZ Publish Community Project Board - Member of the share.ez.no team - Key values: Openness and Innovation.

LinkedIn: http://nl.linkedin.com/in/robinmuilwijk // Twitter: http://twitter.com/i_robin // Skype: robin.muilwijk

Fraser Hore

Thursday 29 July 2010 1:37:21 am

Hi Robin,

Thanks for the suggestions. The path to php is correct, and I haven't been able to get it to run from the command line either. When I try:

c:\users\Fraser\Uniserver\usr\local\php>php.exe C:\Users\Fraser\UniServer\www\site\runcronjobs.php -d -s issat_site ezfindexcontent

I get "Fatal error: require_once(): Failed openning required 'access.php' (include_path='.;C:\php5\pear') in C:\Users\Fraser\UniServer\www\site\kernal\classes\ezscript.php on line 72

When I run the batch file with the code I posted above, it seems to run the script but doesn't seem to find the ini files.

I've also tried using the UniServer portable cron feature with the following settings in cron.ini:

[ezfindexcontent]
start = 2009-09-21 2:56:52
period = 600 ; 10 Mins
path = ..\..\www\site\runcronjobs.php -s issat_site ezfindexcontent
ref =
From the log it seems to at least try to execute the path, but the index is still not generated.

Thanks for any further suggestions!

Gaetano Giunta

Thursday 29 July 2010 2:17:42 am

You need to move to the ezpublis root directory before executing any script, including cronjobs:

C:

cd /Users/Fraser/UniServer/www/site

c:/php5/php.exe runcronjobs.php -d -s issat_site ezfindexcontent

you should be able to set the current dir in the plaified task properties, or just wrap the above lines in a batch file

Principal Consultant International Business
Member of the Community Project Board

Fraser Hore

Thursday 29 July 2010 3:52:00 am

Thanks for the suggestion! Unfortunately when I tried this I got lot of errors:

eZINI Undefined variable: 'DebugAccess', 'ExtensionDirectory', 'ActiveAccessExtensions' and others all in site.ini

PHP: E_Warning array values don't seem to be passed to ezextension.php

eZDB:: instance Database implementation not supported: ezmysql

Robin Muilwijk

Thursday 29 July 2010 4:26:44 am

Ok, quick question to rule out some easy stuff; eZ is installed with eZ Components? And can you check if PHP runs as CLI or CGI?

Thanks Robin

Board member, eZ Publish Community Project Board - Member of the share.ez.no team - Key values: Openness and Innovation.

LinkedIn: http://nl.linkedin.com/in/robinmuilwijk // Twitter: http://twitter.com/i_robin // Skype: robin.muilwijk

Fraser Hore

Thursday 29 July 2010 5:35:03 am

Yes my installation does include eZ Components (at least that's the version I downloaded so I presume it's installed also). I'm not sure where to check if PHP is running in CLI or CGI, but by poking around a little it looks like it's running in CGI.

Thanks for the help!

Robin Muilwijk

Thursday 29 July 2010 6:15:44 am

Hi,

Found the actual command, in a windows commandbox, type "php -v", this should output the version and directly after that CLI or CGI.

As far as I know, running as CGI this causes problems with the cronjobs. CLI is also listed as install requirement for eZ. If you can switch easily to php cli, it might be worth checking if the issue persists or not.

-- Robin

Board member, eZ Publish Community Project Board - Member of the share.ez.no team - Key values: Openness and Innovation.

LinkedIn: http://nl.linkedin.com/in/robinmuilwijk // Twitter: http://twitter.com/i_robin // Skype: robin.muilwijk

Robin Muilwijk

Thursday 29 July 2010 12:01:51 pm

Hi Fraser,

While setting up a scheduled task on my Windows box, which has Wampserver as LAMP stack, I also got the error you have. The runcronjobs.php needs to be called from the root, this means the commandbox/script needs to call it from that directory your eZ install is in. My script:

cd..
cd..
cd wamp\www\ez440en
php runcronjobs.php
pause

What I saw when I started the task, is that the command prompt started at c:\windows\system32. That's incorrect.

So, hence the 2 commands "cd..", this brings the prompt back to c:.

Then make sure the prompt is set to your eZ root, for me that was c:\wamp\www\ez440en

Then the command "php runcronjobs.php"

I've set the "pause" command so I can see when the cronjob is done, what the results are.

Maybe you can try the above, before following my previous advice about trying php on CLI. I think setting the prompt to the correct directory is also Gaentano was referring to.

Hope this is going to work for you, Robin

Board member, eZ Publish Community Project Board - Member of the share.ez.no team - Key values: Openness and Innovation.

LinkedIn: http://nl.linkedin.com/in/robinmuilwijk // Twitter: http://twitter.com/i_robin // Skype: robin.muilwijk

Fraser Hore

Saturday 31 July 2010 2:15:18 pm

Hi Robin,

Thanks for the suggestions!

I discovered using the -v command that I am running php in cli mode. I got a response: PHP 5.3.2 (cli)...

When I try to use the php command anywhere other than the php root directory I get an error: 'php' is not recognized as an internal or external command, operable program or batch file

This is proving a stubborn problem!

Robin Muilwijk

Saturday 31 July 2010 10:39:26 pm

Hi Fraser,

The error you have above need to be solved first, you can then use the .bat example I used to get a cronjob scheduled. What I have in my Path environmental variable is as follow:

;C:\wamp\bin\php\php5.2.6;C:\wamp\bin\php\php5.2.6\ext

If that path is correct for you (you'll need to set your own paths of course), you should be able to run php from any folder. See if you can get that to work first.

Regards Robin

Board member, eZ Publish Community Project Board - Member of the share.ez.no team - Key values: Openness and Innovation.

LinkedIn: http://nl.linkedin.com/in/robinmuilwijk // Twitter: http://twitter.com/i_robin // Skype: robin.muilwijk

Fraser Hore

Sunday 01 August 2010 2:29:11 pm

I changed the path variable so I can run php from the ez root folder, but I still get the error: Error initializing script: database error: No database handler was found for `ezmysql`. And there is a bunch of undefined variable errors in site.ini. It seems that the scrip is not picking up the variable values from the site.ini override.

Robin Muilwijk

Monday 02 August 2010 12:55:46 am

Hi Fraser,

Now that php can be started from the eZ root, can you post the command you use to call the runcronjobs.php? Can you also post the full error log?

Thanks Robin

Board member, eZ Publish Community Project Board - Member of the share.ez.no team - Key values: Openness and Innovation.

LinkedIn: http://nl.linkedin.com/in/robinmuilwijk // Twitter: http://twitter.com/i_robin // Skype: robin.muilwijk