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