You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Installation
Step 1: Download the module into your modules subdirectory.
Step 2: Create table crontab
CREATE TABLE IF NOT EXISTS `crontab` (
`id_crontab` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`period` varchar(50) NOT NULL,
`callback` varchar(140) NOT NULL,
`params` varchar(255) DEFAULT NULL,
`description` varchar(255) DEFAULT NULL,
`date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`date_started` datetime DEFAULT NULL,
`date_finished` datetime DEFAULT NULL,
`date_next` datetime DEFAULT NULL,
`times_executed` bigint DEFAULT NULL,
`output` varchar(50) DEFAULT NULL,
`running` tinyint(1) NOT NULL DEFAULT '0',
`active` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id_crontab`),
UNIQUE KEY `crontab_UK_name` (`name`)
) ENGINE=MyISAM DEFAULT;
Step 3: Enable the module in your bootstrap file:
/**
* Enable modules. Modules are referenced by a relative or absolute path.
*/
Kohana::modules(array(
'cron' => MODPATH.'cron',
// 'auth' => MODPATH.'auth', // Basic authentication
// 'codebench' => MODPATH.'codebench', // Benchmarking tool
// 'database' => MODPATH.'database', // Database access
// 'image' => MODPATH.'image', // Image manipulation
// 'orm' => MODPATH.'orm', // Object Relationship Mapping
// 'pagination' => MODPATH.'pagination', // Paging of results
// 'userguide' => MODPATH.'userguide', // User guide and API documentation
));
Usage
Add in the crontab table new entries to execute your code.
Edit bootstrap.php add at the end the following: Cron::run();
This will run the cron on every request (not recommended, chec advanced).
Advanced Usage
If you have access to the system crontab, you can run Cron once a minute (or less). You will need to modify the lines where the request is handled in your bootstrap file to prevent extraneous output. The default is:
echo Request::factory()
->execute()
->send_headers()
->body();
Change it to:
if ( ! defined('SUPPRESS_REQUEST'))
{
echo Request::factory()
->execute()
->send_headers()
->body();
}
Then set up a system cron job to run your application’s Cron once a minute:
* * * * /usr/bin/php -f /var/www/open-classifieds/oc/modules/common/modules/cron/cron.php
The included cron.php should work for most cases (review path), but you are free to callCron::run() in any way you see fit.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
See/download download this Kohana Module at github.
This module provides a way to schedule tasks (jobs) within your Kohana application. Based on the job done by Chris Bandy https://github.com/cbandy/kohana-cron
Uses vendor mtdowling/cron-expression https://github.com/mtdowling/cron-expression.
Installation
Step 1: Download the module into your modules subdirectory.
Step 2: Create table crontab
Step 3: Enable the module in your bootstrap file:
Usage
Add in the crontab table new entries to execute your code.
Edit bootstrap.php add at the end the following: Cron::run();
This will run the cron on every request (not recommended, chec advanced).
Advanced Usage
If you have access to the system crontab, you can run Cron once a minute (or less). You will need to modify the lines where the request is handled in your bootstrap file to prevent extraneous output. The default is:
Then set up a system cron job to run your application’s Cron once a minute:
* * * * /usr/bin/php -f /var/www/open-classifieds/oc/modules/common/modules/cron/cron.php
The included cron.php should work for most cases (review path), but you are free to callCron::run() in any way you see fit.
Original
https://garridodiaz.com/kohana-cron/
Beta Was this translation helpful? Give feedback.
All reactions