• Online Demo
  • 30-day Free Trial
  #1  
Old 07-13-2012, 06:52 PM
VincentvDaal VincentvDaal is offline
Junior Member
 
Join Date: Jul 2012
Posts: 3
Default Cron last ran keeps "unknown"

Hi.

I'm checking out blesta, and so far liking it!
However, it seems I can't get the crons to work.
My folder structure looks like the following:
Code:
/home/vvandaal
   /cron
   /public_html
         /client (directory with all blesta files)
   /uploads
I also have my cron directory set as: /home/vvandaal/cron

And when I manually ran php -q /home/vvandaal/public_html/client/cronjob.php KEYHERE all
or do the wget command, it returns no errors or any output.

Also when I manually run the cron, no errors....

In any case the "cron last ran" keeps saying "unknown".
So I believe it's not working.

Code:
root@srv01 [/home/vvandaal]# cat /etc/redhat-release
CentOS release 6.3 (Final)
How can I resolve this?

Last edited by VincentvDaal; 07-13-2012 at 06:54 PM.
Reply With Quote
  #2  
Old 07-14-2012, 06:26 AM
Paul's Avatar
Paul Paul is offline
Blesta Developer
 
Join Date: Apr 2006
Location: Wherever I go, there I am.
Posts: 1,465
Send a message via AIM to Paul Send a message via MSN to Paul
Default

Definitely sounds like it's not running properly. Check your Cron Directory path under Settings > API/Cron Settings. It should be the full path to the cron directory, likely...

/home/vvandaal/cron/

If that is correct and you still don't get any output, edit inc/config.php and set error_reporting(0); to error_reporting(E_ALL & ~E_NOTICE); and try again.. you should get some type of error. If you don't, you might need to update the same in your php.ini.
__________________
Paul
Misc Stuff Guy

Blesta
Professional Billing
www.blesta.com
Reply With Quote
  #3  
Old 07-14-2012, 12:42 PM
VincentvDaal VincentvDaal is offline
Junior Member
 
Join Date: Jul 2012
Posts: 3
Default

Wow...why didn't I think of that :-)
'Doh.

I'm checking right now what's exactly going on but seems my PHP needs a recompile.
Reply With Quote
  #4  
Old 07-14-2012, 01:02 PM
VincentvDaal VincentvDaal is offline
Junior Member
 
Join Date: Jul 2012
Posts: 3
Default

Now this is odd...
I'm going to explain exactly how I setup blesta:
I downloaded the "ionCube php 5.3" file through wget and then extracted it through tar.

You might be interested to know how the "cronjob.php" file looks like then:
Note, I am not trolling here, it was all on one line :P

PHP Code:
<?php/**  NOTES ON THIS CRON FILE*  --*  1. This file should be run every 15 minutes.*  2. The key parameter is your Remove Access Key.  You can set this in [Settings] > [API/Cron Settings] > [API Control Options]*  3. Below is an example of the cron line (for more examples see [Settings] > [API/Cron Settings]):*     GET -t 15m http://www.yourdomain.com/cronjob.php?key=abcdefg1234567&cron=all > /dev/null 2>&1 &*/#$path_to_cron = "../../cron/"; // The relative path to your cron directory -- must end with a / (forward slash)/***************** DO NOT EDIT ANYTHING BELOW THIS LINE ***********************/set_time_limit(900); // Allow 15-minutes for this script to run// Check for key passed via command lineif (isset($_SERVER['argc']) && $_SERVER['argc'] > 1) {    $_GET['key'] = $_SERVER['argv'][1];    $_GET['cron'] = $_SERVER['argv'][2];}if (!$_GET['key'])    die;$dir = dirname(__FILE__) . "/";include($dir . "inc/config.php");include($dir . "inc/init_lang.php");include($dir . "inc/mime.class.php");$path_to_cron = settval($mysqldb, "cronpath");if (file_exists($path_to_cron))    $full_path = realpath($path_to_cron) . "/";else    die("\$path_to_cron:" . $path_to_cron . " is invalid");//  Establish a connection to the database.$mysqldb = new mysql(SQLHOST, SQLUSER, SQLPASS, SQLDB);$mysqldb->connect();$mysqldb->select();// Do key checkingif (!validateKey($mysqldb, $_GET['key']))    die("Key validation failed.");logCron($mysqldb, 'attempted');// Choose the cron to runswitch ($_GET['cron']) {    case "bill-cron":        include($full_path . "bill-cron.php");        break;    case "suspend":        include($full_path . "suspend.php");        break;    case "db-backup":        include($full_path . "db-backup.php");        break;    case "exchange-rates":        include($full_path . "exchange-rates.php");        break;    case "pop3-tickets":        include($full_path . "pop3-tickets.php");        break;    // Run all crons    case "all":    default:        include($full_path . "bill-cron.php");        include($full_path . "suspend.php");        include($full_path . "db-backup.php");        include($full_path . "exchange-rates.php");        break;}?>
Meaning, my server didn't process about everything in it, since it was "commented out".
I've opened up the file, applied some code formatting and now it works.

PHP Code:
<?php
/**  NOTES ON THIS CRON FILE*  --*  
1. This file should be run every 15 minutes.*  
2. The key parameter is your Remove Access Key.  You can set this in [Settings] > [API/Cron Settings] > [API Control Options]*  
3. Below is an example of the cron line (for more examples see [Settings] > [API/Cron Settings]):*     

GET -t 15m http://www.yourdomain.com/cronjob.php?key=abcdefg1234567&cron=all > /dev/null 2>&1 &*/
#$path_to_cron = "../../cron/"; 
// The relative path to your cron directory -- must end with a / (forward slash)

/***************** DO NOT EDIT ANYTHING BELOW THIS LINE ***********************/

set_time_limit(900); // Allow 15-minutes for this script to run
// Check for key passed via command line

if (isset($_SERVER['argc']) && $_SERVER['argc'] > 1) {    
$_GET['key'] = $_SERVER['argv'][1];    
$_GET['cron'] = $_SERVER['argv'][2];
}
if (!
$_GET['key'])    die;$dir dirname(__FILE__) . "/";

include(
$dir "inc/config.php");
include(
$dir "inc/init_lang.php");
include(
$dir "inc/mime.class.php");

$path_to_cron settval($mysqldb"cronpath");

if (
file_exists($path_to_cron))    $full_path realpath($path_to_cron) . "/";
else    
die(
"\$path_to_cron:" $path_to_cron " is invalid");

//  Establish a connection to the database.

$mysqldb = new mysql(SQLHOSTSQLUSERSQLPASSSQLDB);$mysqldb->connect();
$mysqldb->select();
// Do key checking

if (!validateKey($mysqldb$_GET['key']))    die("Key validation failed.");
logCron($mysqldb'attempted');
// Choose the cron to run
switch ($_GET['cron']) {    
case 
"bill-cron":        
    include(
$full_path "bill-cron.php");        
    break;    
case 
"suspend":        
    include(
$full_path "suspend.php");        
    break;    
case 
"db-backup":        
    include(
$full_path "db-backup.php");        
    break;    
case 
"exchange-rates":        
    include(
$full_path "exchange-rates.php");        
    break;    
case 
"pop3-tickets":        
    include(
$full_path "pop3-tickets.php");        
    break;    
// Run all crons    
case "all":    default:        
    include(
$full_path "bill-cron.php");        
    include(
$full_path "suspend.php");        
    include(
$full_path "db-backup.php");        
    include(
$full_path "exchange-rates.php");        
break;
}
?>
Might be worth changing the formatting of the file for future releases (I've read about V3, so might be not an issue then).
It's working great now!

Strange huh? :-)
Reply With Quote
  #5  
Old 07-14-2012, 03:28 PM
Paul's Avatar
Paul Paul is offline
Blesta Developer
 
Join Date: Apr 2006
Location: Wherever I go, there I am.
Posts: 1,465
Send a message via AIM to Paul Send a message via MSN to Paul
Default

Glad it's working!

Not sure why it ended up all on one line for you, pretty strange.
__________________
Paul
Misc Stuff Guy

Blesta
Professional Billing
www.blesta.com
Reply With Quote
Reply

Bookmarks

Tags
cronjob

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Ticket Piping cron issue - Debian Squeeze JimmyK General Discussion 13 06-26-2012 10:31 PM
Cron Setup richwalker Blesta Related 1 07-01-2011 02:11 AM
CGI Error on Cron settings page voicedata General Discussion 1 03-25-2010 06:23 PM


All times are GMT. The time now is 02:12 AM.