本文整理汇总了PHP中Cron类的典型用法代码示例。如果您正苦于以下问题:PHP Cron类的具体用法?PHP Cron怎么用?PHP Cron使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cron类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetNextWithTimestamp
public function testGetNextWithTimestamp()
{
$tz = new DateTimezone('Europe/Berlin');
$dt = new DateTime('2014-12-31 23:42', $tz);
$cron = new Cron('45 9 29 feb thu', $tz);
$this->assertEquals(1709196300, $cron->getNext($dt->getTimestamp()));
}
示例2: run
/**
* Entry point for the back ground worker
*/
public static function run()
{
$notifications = new Notifications();
$subscriptions = new Subscriptions();
$cron = new Cron($notifications, $subscriptions);
$cron->pushNotifications();
}
示例3: activate
/**
* Activate WP Currencies.
*
* What happens when WP Currencies is activated.
*
* @since 1.4.0
*/
public static function activate()
{
self::create_tables();
$cron = new Cron();
$cron->schedule_updates();
do_action('wp_currencies_activated');
}
示例4: testIsValidFor
/**
* @dataProvider isValidForProvider
* @param int $time
* @param string $expression
* @param bool $expectedResult
*/
public function testIsValidFor($time, $expression, $expectedResult)
{
$eventMock = $this->getMock('Magento\\Framework\\Event', [], [], '', false);
$this->cron->setCronExpr($expression);
$this->cron->setNow($time);
$this->assertEquals($expectedResult, $this->cron->isValidFor($eventMock));
}
示例5: run
function run($config)
{
$this->setConfig($config);
$this->setDbAdapter();
$this->setView();
$this->setInit();
$cron = new Cron($this->registry);
$cron->index();
}
示例6: poorMansCron
static function poorMansCron()
{
$intervals = array("minute", "five", "fifteen", "hour", "week");
foreach ($intervals as $interval) {
$entity = getEntity(array("type" => "Cron", "metadata_name" => "interval", "metadata_value" => $interval));
if (!$entity) {
$entity = new Cron();
$entity->interval = $interval;
$entity->save();
}
Cron::run($interval, false);
}
return;
}
示例7: run
static function run($interval, $ignore_last_run = true)
{
$phpbin = PHP_BINDIR . "/php";
if ($ignore_last_run) {
shell_exec('echo $phpbin -q ' . SITEPATH . 'cron/' . $interval . '.php | at now');
return;
}
$entity = getEntity(array("type" => "Cron", "metadata_name" => "interval", "metadata_value" => $interval));
if (!$entity) {
$entity = new Cron();
$entity->interval = $interval;
$entity->save();
}
$last_ran = $entity->last_ran;
if (!$last_ran) {
$last_ran = 0;
}
switch ($interval) {
case "minute":
$seconds = 60;
break;
case "five":
$seconds = 60 * 5;
break;
case "fifteen":
$seconds = 60 * 15;
break;
case "hour":
$seconds = 60 * 60;
break;
case "week":
default:
$seconds = 60 * 60 * 24 * 7;
break;
}
$time = time();
if ($time > $last_ran + $seconds) {
$shell = $phpbin . ' -q ' . SITEPATH . 'cron/' . $interval . '.php > /dev/null 2>/dev/null &';
shell_exec($shell);
$last_ran = $time;
$entity = getEntity(array("type" => "Cron", "metadata_name" => "interval", "metadata_value" => $interval));
if ($entity) {
$entity->last_ran = $last_ran;
$entity->save();
}
}
return;
}
示例8: initialize
/**
*
* Initializes configs for the APP to run
*/
public static function initialize()
{
/**
* Load all the configs from DB
*/
//Change the default cache system, based on your config /config/cache.php
Cache::$default = Core::config('cache.default');
//is not loaded yet in Kohana::$config
Kohana::$config->attach(new ConfigDB(), FALSE);
//overwrite default Kohana init configs.
Kohana::$base_url = Core::config('general.base_url');
//enables friendly url @todo from config
Kohana::$index_file = FALSE;
//cookie salt for the app
Cookie::$salt = Core::config('auth.cookie_salt');
/* if (empty(Cookie::$salt)) {
// @TODO missing cookie salt : add warning message
} */
// -- i18n Configuration and initialization -----------------------------------------
I18n::initialize(Core::config('i18n.locale'), Core::config('i18n.charset'));
//Loading the OC Routes
// if (($init_routes = Kohana::find_file('config','routes')))
// require_once $init_routes[0];//returns array of files but we need only 1 file
//faster loading
require_once APPPATH . 'config/routes.php';
//getting the selected theme, and loading options
Theme::initialize();
//run crontab
if (core::config('general.cron') == TRUE) {
Cron::run();
}
}
示例9: run
function run()
{
global $ost;
Cron::run();
$ost->logDebug('Cron Job', 'Cron job executed [' . $_SERVER['REMOTE_ADDR'] . ']');
$this->response(200, 'Completed');
}
示例10: initialize
/**
*
* Initializes configs for the APP to run
*/
public static function initialize()
{
//enables friendly url
Kohana::$index_file = FALSE;
//temporary cookie salt in case of exception
Cookie::$salt = 'cookie_oc_temp';
//Change the default cache system, based on your config /config/cache.php
Cache::$default = Core::config('cache.default');
//loading configs from table config
//is not loaded yet in Kohana::$config
Kohana::$config->attach(new ConfigDB(), FALSE);
//overwrite default Kohana init configs.
Kohana::$base_url = Core::config('general.base_url');
//cookie salt for the app
Cookie::$salt = Core::config('auth.cookie_salt');
// i18n Configuration and initialization
I18n::initialize(Core::config('i18n.locale'), Core::config('i18n.charset'));
//Loading the OC Routes
require_once APPPATH . 'config/routes.php';
//getting the selected theme, and loading options
Theme::initialize();
//run crontab
if (core::config('general.cron') == TRUE) {
Cron::run();
}
}
示例11: __construct
public function __construct()
{
parent::__construct();
$this->chmod();
echo '<br />' . t('Done!') . '<br />';
echo t('The Jobs Cron is working to complete successfully!');
}
示例12: actionUpdate
public function actionUpdate($id)
{
$form = new TestForm();
if ($form->load($_POST)) {
$test = Test::findOne($id);
//Confere se usuário tem permissão para editar teste na origem OU no destino
$source = $test->getSourceDomain()->one();
$destination = $test->getDestinationDomain()->one();
$permission = false;
if ($source && RbacController::can('test/delete', $source->name)) {
$permission = true;
}
if ($destination && RbacController::can('test/delete', $destination->name)) {
$permission = true;
}
if (!$permission) {
Yii::$app->getSession()->addFlash("warning", Yii::t("circuits", "You are not allowed to update a automated test involving these selected domains"));
return false;
}
$cron = Cron::findOneTestTask($id);
$cron->freq = $form->cron_value;
$cron->status = Cron::STATUS_PROCESSING;
if ($cron->save()) {
Yii::$app->getSession()->addFlash("success", Yii::t("circuits", "Automated Test updated successfully"));
return true;
}
}
return false;
}
示例13: run
function run()
{
//called by outside cron NOT autocron
Cron::MailFetcher();
Cron::TicketMonitor();
cron::PurgeLogs();
}
示例14: init
public static function init()
{
if (!isset($_GET['cronTok'])) {
return;
}
define('EDUCASK_ROOT', dirname(getcwd()));
require_once EDUCASK_ROOT . '/core/classes/Bootstrap.php';
Bootstrap::registerAutoloader();
$database = Database::getInstance();
$database->connect();
if (!$database->isConnected()) {
return;
}
Bootstrap::initializePlugins();
$cron = new Cron($_GET['cronTok']);
$cron->run();
}
示例15: __construct
public function __construct()
{
if (isset(self::$current)) {
throw new ConstructionException('Cannot construct more than one instance of singleton class Cron.');
}
$this->_parse_arguments();
self::$current = $this;
}