Forums / General / Running eZ publish scripts via the command line

Running eZ publish scripts via the command line

Author Message

kracker (the)

Monday 09 May 2005 7:04:08 am

Marat,

Like all things in life; you like all the others can become fluent in eZ publish starting with imitation. I urge you to continue in this way until you can stand and run on your own.

Upon review of your message I see only one problem with your current understanding.

A cron job, is a task which has been programmed to be automated with programing to be started and completed by the computer in an automated fashion without human interaction.

Cron or Crontab are just a few of the freely available software applications which can run commands (cronjobs) at a specified time.

The eZ publish cronjobs script, runcronjobs.php requires a fairly new and generally unknown php application in order to run.

The application is called php (cli), php-cli, etc ...

<b>php-cli</b>

php-cli (as i have coined it) is a very small binary application that is basically php "for the command line", designed for running scripts from a command line instead of from a web application / web server.

By default eZ publish scripts assume (incorrectly) that a user will call these scripts with a the cli version of php installed. There are at least three versions of php (cli,cgi,dso).

Most users would not have the cli version or know about it. This is a failure by the eZ publish documentation team, in not correctly explaining these obfuscated dependencies to users who lack the required foreknowledge to understand and comply with these dependencies without being told in advance.

The solution as I tried to explain to the community with Bjorn back in mid 2004...

Download and copy my provided php-cli binary application for linux computers (using glibc).

Install the php-cli binary application into bin/linux/ as bin/linux/php-cli

Call your eZ publish runcronjobs.php like this, to test these instructions.

./bin/linux/php-cli runcronjobs.php

I would call upon the rest of the advanced eZ publish developers in the community, post a link to a php-cli binarry application for windows users.

Unfortunately, I do not belive eZ systems can add this php-cli binary application (despite how much I wish it so for the simplicity of the entire distribution) as the php-cli binary's licence would conflict with eZ publish's.

Crontab

While most people say the word cron when they reference automated / timed tasks. The actual application used by most users to use cron is called : <i>crontab</i>. To use crontab directly you must login via your sever's provided shell access (ssh) to use the crontab application.

List crontab entries:

crontab -l

Edit your crontab, add entries:

 crontab -e

<i>Warning, crontab will open up your shell's default text editor, which is often vi . I would review a vi guide to know just how to use the text editor which for new users can be at times frustrating and confusing, but then what isn't in software?</i>

The Summary

>> Please, help me understand how eZ publish processes workflows and how the server should be tuned. So that in the future I could at least localize the problem myself.

It's ill advised to ask a long question series of line item questions and summarize it by asking an almost completely different question, I counter suggest a bulleted list of key lines / key notes in it's stead.

Still I'm quite the .... today so I will cover the bulk of your question before the summary.

I hope these answers find you well.

//kracker

<i>References:
http://www.google.com/search?hl=en&q=crontab%2C+examples&btnG=Google+Search
http://www.gentoo.org/doc/en/vi-guide.xml

http://www.ez.no/ez_publish/documentation/incoming/setup_php_for_comandline_usage_php_cli
http://www.ez.no/ez_publish/documentation/incoming/setup_php_for_comandline_usage_php_cli/pre_compiled_php_cli_linux_binary_available

http://www.google.com/search?hl=en&q=php-cli%2C+windows&btnG=Google+Search
http://www.google.com/search?as_q=php-cli&sourceid=mozilla-search&start=0&start=0&ie=utf-8&oe=utf-8&num=50&as_qd=all&as_ft=i&as_qdr=all&as_occt=any&as_dt=i&as_sitesearch=ez.no
http://www.ez.no/content/search?SearchText=php-cli
</i>

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Marat M.

Monday 09 May 2005 8:06:38 am

hi, kracker,

I've downloaded the file from here

http://ezpub.co.uk/files/fixes

Then unpacked it into

http:[mysite]/ez_directory/bin/linux 

and named "php-cli".

What I didn't understand is "Call your eZ publish runcronjobs.php like this, to test these instructions"

What should I use to call? Command line? I thought that CMD is used to call local files. But my site is on a shared hosting...

kracker (the)

Monday 09 May 2005 8:42:21 am

Maret,

You almost have it, keep trying!

To run the script: runcronjobs.php

You must run this command (below) inside of a command line window (also called ssh):

./bin/linux/php-cli runcronjobs.php

Testing this way <b>requires</b> ssh access to your shared hosting provider.

Honestly if your shared hosting provider does not provide ssh access to the server your being ripped off and should seek a replacement hosting provider.

I would recommend choosing one from the list of eZ publish Hosting Partners:

http://www.ez.no/partner/partner_list/(partner)/hosting/(sort)

Alternately,

Ask your provider just how you can use cron or crontab on your shared hosting provider (perhaps via a control panel of some kind)

cheers,
//kracker

Sage Francis : Bounce - Live at the Met Cafe

<i>Disclaimer: I have an interest in seeing you acquire improved hosting service ... I know better.</i>

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Marat M.

Monday 09 May 2005 10:43:34 am

Thanks, cracker. I will try to use some of the hostings you offer that is primarily intended for eZPublish usage.

Still I'm learning the features of eZPublish and it seems I have all that is necessary to run my site. However, there is one small though interesting question I posted here

http://ez.no/community/forum/general/a_policy_for_a_separate_content_object

Best,
Marat

Marat M.

Monday 09 May 2005 11:01:57 am

BTW, I asked my hosting provider, and this is what they answered:

"Our hosting is on windows machines so we suggest another solution for scheduled scripts execution. You can place one of these files into the root directory of your site:

_cron01.php - every minutute
_cron60.php - every hour
_cron1440.php - every 24 hours

And they will be executed as specified."

So, my only lame question is - what to write into those files :))

Thanks in advance,
Marat

kracker (the)

Tuesday 10 May 2005 12:42:21 am

Well,

I don't develop using windows so it is harder for me to answer with certainty. Judging by the silence in my absence I gather that not many advanced eZ publish developers do either ...

In fact I believe that eZ systems only recommends hosting eZ publish applications on GNU/Linux servers.

Still, I started this so I should end it.

I found these links which talk in great detail about php-cli:
<i>http://book.itzero.com/read/others/0503/Prentice.Hall.PTR.PHP.5.Power.Programming.Oct.2004.eBook-LiB_html/013147149X/ch16lev1sec2.html</i>

As well as this document talking about finding the php-cli windows (binary) application in a windows server.

<i>http://www.zend.com/manual/install.windows.manual.php
http://www.zend.com/manual/install.windows.building.php</i>

As for your cron I would write a php script to call the cronjob (the windows way) inside a php script using the php-cli binary provided by your hosting provider's php installation (assuming they provide php-cli), then rename this custom script, to the frequency you wish to have it run.

_cron60.php

Upon even further review, I have found this bug which talks about custom installing the missing php-cli application on windows: <i>http://www.ez.no/community/bugs/runcronjobs_php_fails_with_windows_downloadable_package</i>

Per the above suggestions in the (above) bug, I have packaged the 'Windows : php (cli) v4.3.11' Binary for users of windows to get/use quickly and simply.

<i>http://download.ezpublishhosting.com/php-cli/windows/php-cli.zip</i>

Best Wishes,

//kracker

<i>Quincy Jones : Ironside (Excerpt)
The 5.6.7.8's : Woo Hoo
Zamfir : The Lonely Shepherd
</i>

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

kracker (the)

Tuesday 10 May 2005 1:46:57 am

I've also gone ahead and written a wrapper script which you should be able to use in your specific situation as a drop in solution.

// #!c:\php\php.exe -q
/*
 Author: kracker
 Date: 05/09/2005
 License: GNU GPL (v2 or later)
 Description: Windows php script wrapper to call eZ publish : runcronjobs

 This (albeit little script) is expressly provided only
 under the terms of the GNU GPL. Just so we are clear :)
*/

system("cd /web/the-path-to-ez/; c:\php\cli\php.exe /web/the-path-to-ez/runcronjobs.php");

//exit();

As for your cron I would write the above into a php script file named ...

_cron60.php

I can't test this code but from my collected experiances ( I was young, I didn't know any better ...) this should work without modifications.

I only would make sure the file's permissions are set to allow this to be an executable file? I'm not certain how they handle that in windows perhaps it's a non-issue. Testing / Bug reports welcome (just post it to this thread).

<i>Everyone, sing with me ...</i>

Cheers,
//kracker

<i>Sole : Live from Rome : Crisis</i>
<i>Sole : Live from Rome : Every Single One of Us</i>

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Marat M.

Tuesday 10 May 2005 4:39:02 am

You know, I more and more incline to use eZPublish powered hosting instead of ordinary hosting. Even if I correctly make all the adjustments there is no guarantee that something will not work properly in future. So I will choose from the eZpublish hosting providers.

Thanks for you help,

- Marat