Welcome Guest, Not a member yet? Register   Sign In
Cron problem
#1

[eluser]Ajaxian64[/eluser]
Hi all,
I've update my web app from CI 1.7.x to 2.0

Before this upgrade, my cron task worked fine but since Ci 2.0 then it doesn't work
Code:
// Emulate the http request
    $_SERVER['PATH_INFO'] = '/users/freeMe';
    $_SERVER['REQUEST_URI'] = '/users/freeMe';
    $_GET = '';
The result I have is that CI doesn't recognize the url and the Router class said "No URI present. Default Controller Set"

Is there something changed in CI 2.0 regarding this ?
#2

[eluser]InsiteFX[/eluser]
Some one posted this the other day and had the same problem.

This is how they said it worked for them in CI 2.0.1. You can search the forum for it.
Code:
/usr/bin/php index.php welcome cron

InsiteFX
#3

[eluser]Ajaxian64[/eluser]
I read the post but I don't know where is the solution
I use a cron.php in which I set the lines I have given previously AND I'm totally unable to know where I shall put the
Code:
/usr/bin/php index.php welcome cron

This is what I have in my cron.php
Code:
define('CRON_CI_INDEX', 'path/www/index.php');   // Your CodeIgniter main index.php file
    define('CRON', TRUE);   // Test for this in your controllers if you only want them accessible via cron


// Simulate an HTTP request

    $_SERVER['PATH_INFO'] = '/freedom/freeMe';
        // In my config.php I have $config['uri_protocol' = 'AUTO';
       // When I set $_SERVER['REQUEST_URI']= '/freedom/freeMe'; and in config.php
       //$config['uri_protocol' = 'REQUEST_URI'; Then It fails due to Undefined index:
       //  SCRIPT_NAME
    $_SERVER['AUTO'] = '/freedom/freeMe';
    $_GET = '';
    
    if(!defined('CRON_LOG')) define('CRON_LOG', 'cron.log');
    if(!defined('CRON_TIME_LIMIT')) define('CRON_TIME_LIMIT', 0);


// Set run time limit
    set_time_limit(CRON_TIME_LIMIT);


# Run CI and capture the output
    ob_start();
    

    chdir(dirname(CRON_CI_INDEX));
    include(CRON_CI_INDEX);           // Main CI index.php file
    $output = ob_get_contents();
    
    
    ob_end_clean();
Then I don't know where to place the
Code:
/usr/bin/php index.php welcome cron
#4

[eluser]Ajaxian64[/eluser]
When I did
Code:
$_SERVER['AUTO'] = '/freedom/freeMe';
Then the router class doesn't recognise the uri and said that uri is not existing. And It routes me to the default controller

When I use instead
Code:
$_SERVER['REQUEST_URI'] = '/freedom/freeMe';
then I get an error :
Code:
<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  Undefined index:  SCRIPT_NAME</p>
<p>Filename: core/URI.php</p>
<p>Line Number: 149</p>
It seems that SCRIPT_NAME is unknown
Entirely lost the Ajaxian boy ...
Up to you is it due to server ? cron.php which may be bad, attack from Mars?
#5

[eluser]Unknown[/eluser]
Use the below command in the cpanel cron command section

lynx -dump http://siteurl/cron.php

Place the below cron.php in the root folder

#!/usr/local/bin/php
&lt;?php
$_SERVER['REQUEST_URI'] = '/controller_name/function_name';
require 'index.php';
?&gt;

You can add the cron functions in the specified controller and that function will execute if you call the cron.php script in the root

Hope this may help for the cgi Server




Theme © iAndrew 2016 - Forum software by © MyBB