Welcome Guest, Not a member yet? Register   Sign In
Run CI from cron
#5

[eluser]eger[/eluser]
That MY URI looks neat and simplifies a little bit of what I previously found. I had copied and modified the index.php to call a specific controller and method. I placed it in application/cli (though it could probably be somewhere more secure) and added PATH_INFO and absolute folder paths:
Code:
<?php

$_SERVER['PATH_INFO'] = '/graph/plot';
error_reporting(E_ALL);
$system_folder = "/home/stats/public_html/stats";
$application_folder = "/home/stats/public_html/stats/application";

if (strpos($system_folder, '/') === FALSE)
{
    if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
    {
        $system_folder = realpath(dirname(__FILE__)).'/'.$system_folder;
    }
}
else
{
    // Swap directory separators to Unix style for consistency
    $system_folder = str_replace("\\", "/", $system_folder);
}

define('EXT', '.'.pathinfo(__FILE__, PATHINFO_EXTENSION));
define('FCPATH', __FILE__);
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define('BASEPATH', $system_folder.'/');

if (is_dir($application_folder))
{
    define('APPPATH', $application_folder.'/');
}
else
{
    if ($application_folder == '')
    {
        $application_folder = 'application';
    }

    define('APPPATH', BASEPATH.$application_folder.'/');
}

require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;

Then I would add a cronjob for "/usr/bin/php -q /home/stats/public_html/stats/application/cli/logprocess.php".


Messages In This Thread
Run CI from cron - by El Forum - 02-09-2009, 12:16 PM
Run CI from cron - by El Forum - 02-09-2009, 12:46 PM
Run CI from cron - by El Forum - 02-09-2009, 02:05 PM
Run CI from cron - by El Forum - 02-09-2009, 02:22 PM
Run CI from cron - by El Forum - 02-09-2009, 05:36 PM
Run CI from cron - by El Forum - 02-09-2009, 07:59 PM
Run CI from cron - by El Forum - 02-11-2009, 04:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB