开发者

Kohana 3 and CRON always accessing index.php (not following the URI argument)

开发者 https://www.devze.com 2022-12-24 12:11 出处:网络
OK, I hope this is my last question about CRON jobs and Kohana 3. Note: others are not duplicates, just other problems.

OK, I hope this is my last question about CRON jobs and Kohana 3. Note: others are not duplicates, just other problems.

Here is my CRON job (setup in cPanel)

php /home/user/public_html/index.php --uri=properties/update

As per this answer.

I have set it up so it emails me the output. It is running every 5 mins.

Unfortunately, it always emails me the source of the home page of my site (index.php or /).

I can access that URL fine in my browser, i.e. http://www.example.com/properties/update and it works and does its job correctly. I can tell the Cron is never hitting the script because I have a file logger in place.

Would this have anything to do with .htaccess?

Has this happened to anyone before, and how did they fix it?

Many thanks.

Update

Here is my home route in bootstrap.php if anyone is interested.

Route::set('home', '')
    ->defaults(array(
    'controller' => 'home',
    'action' => 'index'
    ));

It is the first route defined.

Another Update

开发者_JAVA百科

What's weird too, is that a var_dump(Kohana::$is_cli); produces false when emailed from the CRON.


In case anyone else has this problem, after spending hours trying to work it out, I eventually discovered that instead of using (to use your example)

php /home/user/public_html/index.php --uri=properties/update

I had to use

/usr/local/bin/php -q /home/user/public_html/index.php --uri=properties/update

The exact path to php may vary, but without using this, it wasn't using CLI, and although I'm not entirely sure, I think it was CURLing it.

I also found that I had to explicitly state the index actions too, when calling those; they weren't called as the controllers' default actions (although oddly, before() was called).


Update your route to:

Route::set('home', '<>')
    ->defaults(array(
    'controller' => 'home',
    'action' => 'index'
    ));

or:

Route::set('home', 'properties/update')
    ->defaults(array(
    'controller' => 'home',
    'action' => 'index'
    ));
0

精彩评论

暂无评论...
验证码 换一张
取 消