Running cronjobs.php with parameters in limited environment

Author Message

Noicokuna Niemoge

Thursday 08 January 2009 5:53:53 am

Hello;

I just wanted to share one solution: running cronjobs when your provider doesn't allow you to run cronjob tasks with parameters and when your server runs php-cgi.

I am allowed to run php files only in cronjob, without any parameters and without the possibility to browse eZ Publish directory. I also don't have command line access. Yeah, this is pretty frustrating, but I can't afford a better hosting solution.

In order to run cronjob task with parameters, you have to create a separate php file and then create a cronjob task pointing to that file.

Here's the code:
(I give an example of data_import extension)

<?php

$output = shell_exec('cd /path/to/ezpublish/; /path/to/php5 runcronjobs.php import_images_csv');

echo "<pre>$output</pre>";

?>

And that's it :D Note that you must have safe mode disabled, but generally it's eZ Publish requirement...

Well, it works for me. Don't bash me if it's too trivial, I'm just starting to learn php. -_- For people new in php as I am, I think it will be a nice hint, I couldn't find this solution in these forums.

Shiki soku ze ku...

Heath

Thursday 08 January 2009 4:01:29 pm

<i>@Noicokuna Niemoge</i>

Thank you for sharing your solution with the rest of the eZ Community.

I have added a reference to eZpedia so others can find your solution in the forum more quickly.

<i>http://ezpedia.org/wiki/en/ez/cronjob</i>

If you don't mind I will write a new solution article archiving your complete solution on eZpedia.

Cheers,
Heath

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

Noicokuna Niemoge

Friday 09 January 2009 5:40:53 am

But of course! I don't mind at all. :)

EDIT: Also, for an extension such as data_import ( http://projects.ez.no/data_import/ ), it's enough to run this php file in a web browser. It creates an output (as seen in the code) so you will know if your import is successful or not.

Shiki soku ze ku...

Heath

Friday 09 January 2009 7:41:49 pm

Feel free to create an eZpedia account and add/subtract/divide from the wiki page.

[0] <i>http://ezpedia.org/wiki/user/register</i>
[1] <i>http://ezpedia.org/wiki/en/ez/solution_running_cronjobs_and_scripts_with_parameters_in_limited_environment</i>

Cheers,
Heath

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 19:31:52
Script start
Timing: Jan 18 2025 19:31:52
Module start 'layout'
Timing: Jan 18 2025 19:31:52
Module start 'content'
Timing: Jan 18 2025 19:31:53
Module end 'content'
Timing: Jan 18 2025 19:31:53
Script end

Main resources:

Total runtime0.6840 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0049 588.1719152.6563
Module start 'layout' 0.00490.0033 740.828139.5078
Module start 'content' 0.00830.6742 780.3359552.2344
Module end 'content' 0.68240.0014 1,332.570312.0938
Script end 0.6839  1,344.6641 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.4527160.0002
Check MTime0.00130.1962160.0001
Mysql Total
Database connection0.00070.109410.0007
Mysqli_queries0.630292.1359600.0105
Looping result0.00050.0782580.0000
Template Total0.650895.120.3254
Template load0.00230.342120.0012
Template processing0.648494.800320.3242
Template load and register function0.00020.032510.0002
states
state_id_array0.00120.172810.0012
state_identifier_array0.00080.120820.0004
Override
Cache load0.00190.2851310.0001
Sytem overhead
Fetch class attribute can translate value0.00080.112620.0004
Fetch class attribute name0.00160.228350.0003
XML
Image XML parsing0.00080.116020.0004
class_abstraction
Instantiating content class attribute0.00000.002260.0000
General
dbfile0.00090.1383170.0001
String conversion0.00000.001040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 22
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs