Jump to content


Photo

Unable to run a PHP script from a web-based Cron Job


  • Please log in to reply
No replies to this topic

#1 toasty

toasty
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 22 October 2006 - 06:21 PM

My host has a very specific method for setting up cron jobs whereby the script needs to be accessible via http.  The support page has an article that details how to set this up if snippet of code wasn't developed for web-access (which is the case for all of mine) and as long as it was a 'curl' statement, I haven't had any problem... but now I'm running into a weird output because I'm trying to access a .php file .... and thus I come here seeking help :)

According to the Knowledge Base article I'm told to do the following (I used all the example file names/locations for testing).
1) Create a file "web.sh" w/in the cgi-bin directory and include the following code
#! /bin/sh
echo "Content-type: text/plain";
echo;
cd "${SITE_ROOT}/var/www/html";
"${SITE_ROOT}/var/www/html/bin/example.pl";
echo "Script completed with exit code $?.";
exit 0;

2) Insert the command into the /bin/example.pl file (the command for the cron job to execute)
php /path_to_file/search/admin/spider.php -u http://www.___________.com/_realdeal/ -r

3) That's it for the setup, to test it I just go to http://www.______.com/cgi-bin/web.sh

When I do this I get one of two error messages.  "Exit Code: 126" showed up a few times until I changed the file permissions to "755".  Then, the following output is what I keep running into.
Status: 400
Content-type: text/html

<b>Security Alert!</b> The PHP CGI cannot be accessed directly.

<p>This PHP CGI binary was compiled with force-cgi-redirect enabled. This
means that a page will only be served up if the REDIRECT_STATUS CGI variable is
set, e.g. via an Apache Action directive.</p>
<p>For more information as to <i>why</i> this behaviour exists, see the <a href="http://php.net/security.cgi-bin">manual page for CGI security</a>.</p>
<p>For more information about changing this behaviour or re-enabling this webserver,
consult the installation file that came with this distribution, or visit
<a href="http://php.net/install.windows">the manual page</a>.</p>
Script completed with exit code 255.

I've gone to both URL's the output's suggested and haven't been able to make any sense of it.  I'm not even sure if a "php" forum is where I need to be inquiring; but I figured since this error's only shown up when trying to run a .php file, hell it'd be a good place to start.

I really appreciate any advise, tips, or solutions anyone might have.  Thanks everyone!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users