Forums / Developer / Running cronjobs.php with parameters in limited environment

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

eZ debug

Timing: Jan 18 2025 16:13:08
Script start
Timing: Jan 18 2025 16:13:08
Module start 'content'
Timing: Jan 18 2025 16:13:09
Module end 'content'
Timing: Jan 18 2025 16:13:09
Script end

Main resources:

Total runtime1.3770 sec
Peak memory usage4,096.0000 KB
Database Queries197

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 589.4141180.7969
Module start 'content' 0.00531.2414 770.2109557.3438
Module end 'content' 1.24670.1302 1,327.5547336.7109
Script end 1.3769  1,664.2656 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.2640210.0002
Check MTime0.00140.0999210.0001
Mysql Total
Database connection0.00070.047610.0007
Mysqli_queries1.309495.08981970.0066
Looping result0.00210.15141950.0000
Template Total1.349198.020.6746
Template load0.00180.133220.0009
Template processing1.347397.838420.6736
Template load and register function0.00020.013110.0002
states
state_id_array0.00080.058210.0008
state_identifier_array0.00100.073120.0005
Override
Cache load0.00150.1116310.0000
Sytem overhead
Fetch class attribute can translate value0.00140.099130.0005
Fetch class attribute name0.00090.062050.0002
XML
Image XML parsing0.00090.065230.0003
class_abstraction
Instantiating content class attribute0.00000.001060.0000
General
dbfile0.00300.2174280.0001
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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