Berlie Posted March 7, 2007 Posted March 7, 2007 (edited) I am setting up a cron job to rerank a topsites list. I am getting a error email message when the cron job tries to execute stating: This script can only be executed by the cli version of PHP. Current executing environment: cgi Does this mean that the cli version (whatever that is) of PHP is not installed on the server? Edited March 7, 2007 by Berlie Quote
TCH-Andy Posted March 7, 2007 Posted March 7, 2007 Can you tell us what the command you have for the cron job is? And the initial bit of the php code ? Are you trying to call the PHP file directly? Or via a CGI script? Have you included the path in the top of the PHP code you are trying to run? >#!/usr/local/bin/php The version on the server should be CLI, I'll check on your server if you can let me know which server you are on. Quote
Berlie Posted March 7, 2007 Author Posted March 7, 2007 (edited) I am on server 83. The command I have for the cron job is: /usr/bin/php /home/***/public_html/cron.php --rerank with *** as my cpanel username It results in the error message email listed above. The instructions from the script documentation say: Using the cron.php Script To use the cron.php script your server will need to have the command line interface (cli) version of PHP installed. If you are not sure about this, contact your server administrator and ask them if the cli version of PHP is installed on the server. You will also need to know where the cli PHP binary is located on the server. In most cases it is in /usr/bin or /usr/local/bin You will need to set a directory path in the cron.php file. This can be done by opening that file in a text editor and modifying the $arphp_directory setting at the top of that file. That setting needs to point to the full directory path where AutoRank PHP is installed on your server (the directory where the cron.php file is located). Once you have made that change, save the cron.php file and make sure the modified file has been uploaded to your server. The cron.php script will accept one of several command line arguments that will tell it which function it should run. --rerank - This will rerank your member accounts. For example, if you wanted to rerank your member accounts every 30 minutes, you would use the following crontab entry: 15,45 * * * * /path/to/php /full/directory/path/to/cron.php --rerank Note that the /full/directory/path/to/ portion would be replaced with the directory path on your server to the directory where the cron.php script is located and /path/to/php would be replaced with the location of the cli version of PHP on your server. I modified the $arphp_directory setting as the instructions asked. Below is the initial part of the script that returns the error with my cpanel username edited out. ><?PHP ## AutoRank PHP ## [url=http://www.jmbsoft.com/license.php]http://www.jmbsoft.com/license.php[/url] $arphp_directory = '/home/***/public_html'; chdir($arphp_directory); $sapi = php_sapi_name(); if( $sapi != 'cli' ) { $message = "<pre>This script can only be executed by the cli version of PHP.\n" . "Current executing environment: <b>$sapi</b></pre>"; if( isset($_SERVER['REQUEST_METHOD']) ) { echo $message; } else { echo strip_tags($message); } exit; } Edited March 7, 2007 by Berlie Quote
Berlie Posted April 8, 2007 Author Posted April 8, 2007 Did you ever find out if cli was on server 83 or should I open a support ticket? Quote
TCH-Bruce Posted April 8, 2007 Posted April 8, 2007 Please open a ticket and ask the techs. Thank you. Quote
TCH-Andy Posted April 9, 2007 Posted April 9, 2007 A ticket is always best for such things, but Yes, it is PHP 4.4.4 (cli) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.