LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   shell script using /etc/cron.hourly to execute cron.php file? (http://www.linuxquestions.org/questions/programming-9/shell-script-using-etc-cron-hourly-to-execute-cron-php-file-33702/)

rioguia 10-25-2002 04:04 AM

shell script using /etc/cron.hourly to execute cron.php file?
 
I have a website I am hosting on my local server. It has some statistics functions that need to be updated. I want to use the /etc/cron.hourly file for this purpose.

The website file that does this is called /opt/ezpublish/sites/default/cron.php.

The redhat FAQ says, "All the sysadmin needs to do is drop a shell script or a link to an executable in one of the directories [referring to /etc/cron.hourly] and it will automatically be run at the appropriate time." Can anyone point me to a resource that would help me write this file?

markus1982 10-25-2002 04:18 AM

In this case you need PHP installed as binary (CGI) and add something like
Code:

#!/usr/bin/php -q
To your php script.

So to compile PHP for that purpose for instance do
Code:

#!/bin/bash

cp php*.tar.bz2 /usr/src
cd /usr/src
bzip2 -dc php*.tar.bz2 | tar xvf -
cd php*
./configure \
        --prefix=/tmp/php \
        --enable-ftp \
        --enable-static \
        --enable-tokenizer \
        --disable-xml \
        --without-pear \
        --with-mysql=/usr \
        --with-config-file-path=/etc \
make
make install
cp php.ini-dist /etc/php.ini
strip /tmp/php/bin/php
mv /tmp/php/bin/php /usr/bin
rm -r /tmp/php /usr/src/php*

You might need to change the variable max_execution_time in /etc/php.ini afterwards (if it's > 30 secs).

Example script:
Code:

#!/usr/bin/php -q
<?php
print "hello world\n";
?>

Remember the php script needs execution rights ... so chmod +x <filename>

fatonsopa 06-11-2008 04:57 AM

hy, can you tell me please where to put those codes ?

Code:

#!/bin/bash

cp php*.tar.bz2 /usr/src
cd /usr/src
bzip2 -dc php*.tar.bz2 | tar xvf -
cd php*
./configure \
        --prefix=/tmp/php \
        --enable-ftp \
        --enable-static \
        --enable-tokenizer \
        --disable-xml \
        --without-pear \
        --with-mysql=/usr \
        --with-config-file-path=/etc \
make
make install
cp php.ini-dist /etc/php.ini
strip /tmp/php/bin/php
mv /tmp/php/bin/php /usr/bin
rm -r /tmp/php /usr/src/php*


Randux 06-11-2008 08:09 AM

The plural of "code" is "code".


All times are GMT -5. The time now is 03:33 PM.