Jump to content

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


toasty

Recommended Posts

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
[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;
[/code]

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

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.
[code]
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.
[/code]

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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.