Help with Kohana 3 and CRON

I set CRON to call the url in Kohana 3.

php /home/user/public_html/index.php my/route/in/bootstrap.php

The url access seems to be fine.

However, I got this error (send back the email that my host sends for CRON)

Undefined index:  HTTP_HOST
SYSPATH/classes/kohana/url.php [ 40 ]

Source url.php

What is in the Kohana system file. Is this because the CRON job does not send HTTP headers?

How can I fix this and make it work (I hope without hacking the kernel files).

Or am I doing CRON wrong?

Update

Pekka provided a good answer , however I would like to avoid modifying the main files (although I will be a last resort).

It would seem that Kohana 3 has CLI support, since there is a static property $is_cli.

http://github.com/kohana/core/blob/master/classes/kohana/core.php#L54

+3
3

, E_STRICT, Kohana - . E_STRICT undefined. undefined, HTTP_HOST PHP CLI.

, script , . - error_reporting, . , , CLI.

, error_reporting() , .

+3

, .

, , , $_SERVER['HTTP_HOST'] CLI, Url URL-. , , URL::site $protocol Request::redirect() RSS- Feed.

, , CRONed URL-, , . , , . , . bootstrap.php :

if ( ! isset($_SERVER['HTTP_HOST'])
{
    $_SERVER['HTTP_HOST'] = '<your-domain-here>';
}

, ( "http" ) URL::base, TRUE. , cli://.

+2

Another solution is to install the cron command as follows:

wget --timeout = 99999 -O / dev / null -q http: // localhost / kohana / url / and / some / segment / or / whatever

+1
source

Source: https://habr.com/ru/post/1737622/


All Articles