eZ Community » Forums » Developer » Run cronjobs on demand?

Run cronjobs on demand?

Run cronjobs on demand?

Monday 22 March 2010 1:50:16 pm - 10 replies

Hello to all,

Instead of waiting to run cronjobs.php at a defined time I would like to run it on demand? Is this possible from a browser (admininstration site).


Monday 22 March 2010 4:01:23 pm


Did you try to execute the following command :

php bin/php/ezexec.php path/to/your/cronjob_script.php

Monday 22 March 2010 5:06:46 pm


But how can this be excecuted from the browser? Can it be done? Is there any workaround?

The runcronjobs does "things" from time to time, If I wanted a recent update of things that the runcronjobs.php does it would be great to (from the admin page) run it and then get the expeted results right away instead of waiting for the time of excecution.

Thanks again!

Monday 22 March 2010 5:45:25 pm

Currently there is no way to achieve this in the administration site.

If you know a bit eZ Publish you can create a custom extension that adds a tab in the admin interface (see menu.ini) that trigger a view of a custom module to execute this command.

Monday 22 March 2010 8:13:55 pm



Ok I know how to add the tab in the admin interface, The view of a custom module I can manage to make it, what I do not understand is how to achieve to make the runcronjobs.php work within a view of a module…


How can I make a view of a module that runs the cronjobs.php? I am missing the “how to” links that triggers the execution of the runcronjobs.php


Monday 22 March 2010 9:15:58 pm

Just call this code in your view :

<span>exec("php bin<span>/</span>php<span>/</span>ezexec<span>.</span>php path<span>/</span>to<span>/</span>your<span>/</span>cronjob_script<span>.</span>php")</span>

It should execute the command like if you were in a unix shell and this should run your cronjob (you can also just run "php runcronjobs.php" to run all cronjobs)

Tuesday 23 March 2010 4:39:54 am

Hello again, thanks for your tip, it has driven me to new ideas….
I have added a new tab at the admin making configurations at the menu.ini (not an extension)
I came up with something I hope will work, I added the following to the new tab menu definition (menu.ini):

[Topmenu_excel]  NavigationPartIdentifier=ezexcelnavigationpart  Name=Tablas de Excel  Tooltip=Export excel table  URL[]  # NOTICE THAT node is not important  URL[default]=content/view/excel/172   Enabled[]  Enabled[default]=true  Enabled[browse]=false  Enabled[edit]=false  Shown[]  Shown[default]=true  Shown[edit]=false  Shown[navigation]=true  Shown[browse]=true

I have added new view-mode of seeing nodes (excel) and within the new view-mode I added the code as you told me that generates:

 exec("php /bin/php/ezexec.php /runcronjobs.php")

but it does not work, maybe I have the path to the cronjobs.php wrong, anyway I run the following from the command prompt:

(this a complete line) c:/ezpublish/php/php c:/ezpublish/ezpublish/bin/php/ezexec.php
c:/ezpublish/ezpublish/runcronjobs.php –s (using default siteaccess)

and the output is :

 #!/usr/bin/env php
Running cronjob part 
Notice: No scripts found for

So, ezexec runs but it seems runcronjobs.php is not doing anything at all if ran with the ezexec.php
Instead if I run the following (using php to execute runcronjobs.php directly)

 c:/ezpublish/php/php runcronjobs.php -dall -s

It works like a charm.
Any Ideas?

thanks again!

Tuesday 23 March 2010 8:54:27 am

Yes of course, I suggested the use of ezexec if you want to launch a specific script (in a custom extension for example.) otherwise you need to launch directly runcronjobs.php

I don't understand all your mechanism how did you manage to create a new view without creating an extension?

Tuesday 23 March 2010 1:08:46 pm


A new view, just go to root/design/admin/template/node/view and create excel.tpl (I am using ezwebin)

indide I just added

 <span>exec("php bin<span>/</span>php<span>/</span>ezexec<span>.</span>php bin<span>/</span>dale<span>.</span>php")</span>

of course this could hve been a more complicated .tpl

The Tab was simply created reading menu.ini and seeing other examples in extensions

So there is no way I can make runcronjobs.php work?

at the prompt:

c:/ezpublish/php/php c:/ezpublish/ezpublish/bin/php/ezexec.php c:/ezpublish/ezpublish/runcronjobs.php –s

does not work, how can this be? Maybe this is the same case when executed from the template.

Tuesday 23 March 2010 1:47:49 pm

I think you really should create an extension and a module in which you can execute what php you want (espcially the exec function).

exec() should not be in a template.

Tuesday 23 March 2010 7:24:07 pm

with some careful coding, you can write php scripts that can be run either via direct cli invocation or as a cronjob. You just need to add some code at beginning of script, similar to this:


if ( !defined('eZRunCronjobs_MaxScriptExecutionTime' ) )
set_time_limit ( 0 );
require 'autoload.php';
$cli = eZCLI::instance();
$cli->setUseStyles( true );
$CLI_FAILURE = $cli->style( 'failure' );
$CLI_FAILURE_END = $cli->style( 'failure-end' );
$CLI_SUCCESS = $cli->style( 'success' );
$CLI_SUCCESS_END = $cli->style( 'success-end' );
$CLI_NOTICE = $cli->style( 'notice' );
$CLI_NOTICE_END = $cli->style( 'notice-end' );
$script = eZScript::instance( array( //'description' => ( "description" ),
//'use-session' => true,
'use-modules' => true,
'use-extensions' => true ) );
} else {


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from