This is how my controller looks like
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Cron extends Controller {
public function before() {
if(!Kohana::$is_cli) ;
}
public function action_index() {
$myFile = "C:\cron.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, "\n");
$stringData = date('Y-m-d H:i:s');
fwrite($fh, $stringData);
fclose($fh);
}
}
?>
I run the script through a command line using this
php "C:\Program Files (x86)\EasyPHP\www\myweb\index.php" --uri=cron/index
where cron is the controller and index is a function.
Now what I need is to run the script every x-minute
When I run the script through the browser, it is only that time that the C:\cron.txt is modified.
I heart by putting this
public function before() {
if(!Kohana::$is_cli) ;
}
was to avoid any access via the browser ?
So,
1. How can I deny access from the browser ?
2. How can I make the code running every x-minute ?
Use these two links to get what you need.Cron Jobs in Kohana 3
A module that can help kohana-cron
Kohana Minion