当前位置: 首页>>代码示例>>PHP>>正文


PHP Cron::add方法代码示例

本文整理汇总了PHP中Cron::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Cron::add方法的具体用法?PHP Cron::add怎么用?PHP Cron::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cron的用法示例。


在下文中一共展示了Cron::add方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: boot

 public function boot()
 {
     // Please note the different namespace
     // and please add a \ in front of your classes in the global namespace
     \Event::listen('cron.collectJobs', function () {
         \Cron::add('example1', '* * * * *', function () {
             $this->index();
             return 'No';
         });
         \Cron::add('example2', '*/2 * * * *', function () {
             // Do some crazy things successfully every two minute
             return null;
         });
         \Cron::add('disabled job', '0 * * * *', function () {
             // Do some crazy things successfully every hour
         }, false);
     });
 }
开发者ID:MehmetNuri,项目名称:faveo-helpdesk,代码行数:18,代码来源:AppServiceProvider.php

示例2: testRunRouteWithKeyWithCorrectSendKey

 /**
  *  Tests the Cron run route with setting up the security key and with sending the right key
  *
  *  @covers \Liebig\Cron\CronServiceProvider
  */
 public function testRunRouteWithKeyWithCorrectSendKey()
 {
     \Event::listen('cron.collectJobs', function () {
         Cron::add('test1', "* * * * *", function () {
         });
         Cron::add('test2', "* * * * *", function () {
             return 'No';
         });
     });
     if ($this->laravelVersion >= 5) {
         \Config::set('liebigCron.cronKey', 'yT7yt3sa4tg5vtlLWbofF95v65FSWWZ8');
         \Config::set('liebigCron.logOnlyErrorJobsToDatabase', false);
     } else {
         \Config::set('cron::cronKey', 'yT7yt3sa4tg5vtlLWbofF95v65FSWWZ8');
         \Config::set('cron::logOnlyErrorJobsToDatabase', false);
     }
     $response = $this->call('GET', 'cron.php', array('key' => 'yT7yt3sa4tg5vtlLWbofF95v65FSWWZ8'));
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals(1, \Liebig\Cron\Models\Manager::count());
     $this->assertEquals(2, \Liebig\Cron\Models\Job::count());
     $jobs = \Liebig\Cron\Models\Job::all();
     $this->assertEquals(2, count($jobs));
     $this->assertEquals('test1', $jobs[0]->name);
     $this->assertEquals('', $jobs[0]->return);
     $this->assertEquals('test2', $jobs[1]->name);
     $this->assertEquals('No', $jobs[1]->return);
 }
开发者ID:hilltool,项目名称:cron,代码行数:32,代码来源:CronTest.php

示例3: app_path

*/
App::missing(function ($exception) {
    return Response::view('home.404');
});
App::error(function (Illuminate\Database\Eloquent\ModelNotFoundException $e) {
    return Response::view('home.404');
});
/*
|--------------------------------------------------------------------------
| Require The Filters File
|--------------------------------------------------------------------------
|
| Next we will load the filters file for the application. This gives us
| a nice separate location to store our route and application filter
| definitions instead of putting them all in the main routes file.
|
*/
require app_path() . '/filters.php';
require app_path() . '/config/validators.php';
ini_set('max_execution_time', 60);
DB::disableQueryLog();
//bind hybrid auth to the container
App::bind('Hybrid_Auth', function () {
    return new Hybrid_Auth(app_path() . '/config/hybridauth.php');
});
Event::listen('cron.collectJobs', function () {
    Cron::add('Sitemap', '0 0 2 * *', function () {
        Helpers::createSitemap();
        return null;
    });
});
开发者ID:samirios1,项目名称:niter,代码行数:31,代码来源:global.php

示例4: add

 function add()
 {
     $model = new Cron();
     $model->add();
     $this->redirect('/cron/');
 }
开发者ID:sov-20-07,项目名称:billing,代码行数:6,代码来源:CronController.php

示例5: cron

 private function cron()
 {
     \Event::listen('cron.collectJobs', function () {
         /**
          * CRON: Alimentación de cola de producciones
          * DESCRIPCION: Alimenta la cola de producciones que se van a procesar
          * EJECUCION: Cada 3 minutos
          */
         \Cron::add(AutoProcess::CRON_PRODUCTIONS_FEED, '*/3 * * * *', function () {
             if (!AutoProcess::isActived(AutoProcess::CRON_PRODUCTIONS_FEED)) {
                 return "Desactivado";
             }
             $productionFeed = new ProductionFeed();
             //Carga datos de producciones (peliculas) en el repositorio
             $productionFeed->loadRepository();
             //Alimenta la cola de actualizaciones de peliculas
             $productionFeed->feedQueue();
             return count($productionFeed->dataRepository) . " Producciones cargadas en cola";
         });
         /**
          * CRON: Seguimiento de produccion
          * DESCRIPCION: Toma las producciones en cola indicadas y las procesa obtienendo todos los datos de la produccion
          * EJECUCION: Cada minuto
          */
         \Cron::add(AutoProcess::CRON_PRODUCTION_TRACK, '* * * * *', function () {
             if (!AutoProcess::isActived(AutoProcess::CRON_PRODUCTION_TRACK)) {
                 return "Desactivado";
             }
             $queue = QueueProductions::where(QueueProductions::ATTR_DATE_PROCESSED, null)->orderBy(QueueProductions::ATTR_ID, "ASC")->take(1)->get();
             foreach ($queue as $production) {
                 $provider = new ProductionProvider($production->name, $production->link);
                 $production_id = $provider->save();
                 //Indica el registro como procesado. Esto ocasiona que la produccion ya no se vuelva a actualizar, hasta una nueva cola.
                 $production->production_id = $production_id;
                 $production->date_processed = DateUtil::getCurrentTime();
                 $production->save();
                 return $production->name . " Agregado";
             }
             return "Sin cola";
         });
         /**
          * CRON: Seguimiento de persona
          * DESCRIPCION: Toma las personas indicadas y las procesa para obtener todos sus datos
          * EJECUCION: Cada minuto
          */
         \Cron::add(AutoProcess::CRON_PERSON_TRACK, '* * * * *', function () {
             if (!AutoProcess::isActived(AutoProcess::CRON_PERSON_TRACK)) {
                 return "Desactivado";
             }
             $queue = QueuePersons::where(QueuePersons::ATTR_DATE_PROCESSED, null)->orderBy(QueuePersons::ATTR_ID, "DESC")->take(1)->get();
             foreach ($queue as $person) {
                 $provider = new PersonProvider($person->name, $person->link);
                 $provider->save();
                 //Indica el registro como procesado. Esto ocasiona que la produccion ya no se vuelva a actualizar, hasta una nueva cola.
                 $person->date_processed = DateUtil::getCurrentTime();
                 $person->save();
                 return $person->name . " Agregado";
             }
             return "Sin cola";
         });
         /**
          * CRON: Envio de correo de notificacion de producciones disponibles
          * DESCRIPCION: Verifica todos las producciones en seguimientos por parte de los usuarios premium y cuando esten disponibles les envia un correo notificandoles
          * EJECUCION: Cada 12 horas
          */
         \Cron::add(AutoProcess::CRON_USER_PRODUCTION_TRACK_SEND_MAIL, '0 */12 * * *', function () {
             if (!AutoProcess::isActived(AutoProcess::CRON_USER_PRODUCTION_TRACK_SEND_MAIL)) {
                 return "Desactivado";
             }
             //Obtiene todos los usuarios premium
             $users = User::where(User::ATTR_ROLE, User::ROLE_SUSCRIPTOR_PREMIUM)->get();
             foreach ($users as $user) {
                 //Obtiene las producciones que siguen que ya se encuentran disponibles y que no sean notificado por correo
                 $productions = $user->tracks()->wherePivot(User::ATTR_TRACK_PIVOT_MAILED, 0)->where(Production::ATTR_STATE, Production::STATE_ACTIVE)->get();
                 if (count($productions) == 0) {
                     continue;
                 }
                 if (count($productions) > 1) {
                     $description_email = "<p>Este mensaje es para informate que varias producciones que te gustaria ver en nuestra plataforma ya se encuentran disponibles y las puedes ver cuando quieras.</p>" . "<div style='text-align:center;'>" . "<h2>Nuevas producciones disponibles para ti</h2>" . "</div>" . "<div style='text-align:center;'>";
                 } else {
                     $description_email = "<p>Este mensaje es para informate que una producción que te gustaria ver en nuestra plataforma ya se encuentran disponible y la puede ver cuando quieras.</p>" . "<div style='text-align:center;'>" . "<h2>Nueva producción disponible para ti</h2>" . "</div>" . "<div style='text-align:center;'>";
                 }
                 foreach ($productions as $production) {
                     //Notifica las producciones disponibles asociadas
                     $description_email .= "<a href='" . AutoProcess::URL_SITE . "production/" . $production->slug . "'><img width='192px' height='289px' style='margin: 0px 10px;' src='" . $production->image . "'></a>";
                     $production->pivot->mailed = 1;
                     $production->pivot->save();
                 }
                 $description_email .= "</div>";
                 //Envia el correo de notificacion del usuario
                 $email = new Email(count($productions) > 1 ? "¡Hay varias producciones que te gustaria ver que ya estan disponible!" : "¡Una producción que te gustaria ver ya esta disponible!", $user[User::ATTR_EMAIL], [Email::VAR_NAME => $user->name, Email::VAR_DESCRIPTION => $description_email]);
                 $email->queue();
             }
             return "Notificaciones realizadas (Si aplican)";
         });
         /**
          * CRON: Genera el sitemap.xml del sitio
          * EJECUCION: Cada Semana
          */
         \Cron::add(AutoProcess::CRON_GENERATE_SITEMAP, '0 0 * * 0', function () {
//.........这里部分代码省略.........
开发者ID:jhospina,项目名称:Project-Egolas,代码行数:101,代码来源:AppServiceProvider.php

示例6: app_path

});
/*
|--------------------------------------------------------------------------
| Require The Filters File
|--------------------------------------------------------------------------
|
| Next we will load the filters file for the application. This gives us
| a nice separate location to store our route and application filter
| definitions instead of putting them all in the main routes file.
|
*/
require app_path() . '/filters.php';
/*
|--------------------------------------------------------------------------
| Lieberg Cron Jobs
|--------------------------------------------------------------------------
|	this will help us excute all our cron job functions
| 	
| 
| 
|
*/
Event::listen('cron.collectJobs', function () {
    Cron::add('update', '* * * * *', function () {
        // Do some crazy things unsuccessfully every minute
        $orders = Order::where('activity', '=', '0')->delete();
        return true;
    });
    Cron::setEnableJob('update');
    $report = Cron::run();
});
开发者ID:bernardowiredu,项目名称:unlocking-site,代码行数:31,代码来源:global.php

示例7: function

<?php

Event::listen('cron.collectJobs', function () {
    Cron::add('daily new churches notification', $_ENV['CRON_DAILY'], function () {
        $churches = Church::yesterday();
        if ($churches && $churches->count() > 0) {
            $data['churches'] = $churches;
            Mail::send('emails.dailynewchurches', $data, function ($message) {
                // michhsin@ccea.org.tw
                $message->to('michhsin@ccea.org.tw', '一領一禱告認領同工')->subject('一領一禱告認領:新加入教會通知 ' . date('Y/m/d'))->bcc('lancetw+1and1@gmail.com', 'lancetw');
            });
        }
    }, true);
});
/*
|--------------------------------------------------------------------------
| Register The Laravel Class Loader
|--------------------------------------------------------------------------
|
| In addition to using Composer, you may use the Laravel class loader to
| load your controllers and models. This is useful for keeping all of
| your classes in the "global" namespace without Composer updating.
|
*/
ClassLoader::addDirectories(array(app_path() . '/commands', app_path() . '/controllers', app_path() . '/models', app_path() . '/database/seeds'));
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
开发者ID:htchien,项目名称:prayerweb,代码行数:31,代码来源:global.php

示例8: function

        Sync::sync('StageMove', Config::get('larafuse::syncStageLimit'));
        Sync::sync('JobRecurringInstance', Config::get('larafuse::syncStageLimit'));
        return null;
    });
    Cron::add('Sync Order Group', Config::get('larafuse::syncOrderGroupTime'), function () {
        Sync::syncOrderGroup(Config::get('larafuse::syncOrderLimit'));
        return null;
    });
    Cron::add('Sync One', Config::get('larafuse::syncOneTime'), function () {
        Sync::sync('Referral', Config::get('larafuse::syncOneLimit'));
        Sync::sync('Campaignee', Config::get('larafuse::syncOneLimit'));
        Sync::sync('FileBox', Config::get('larafuse::syncOneLimit'));
        return null;
    });
    Cron::add('Sync Missing', Config::get('larafuse::syncMissingTime'), function () {
        Sync::syncMissing();
        return null;
    });
    $report = Cron::run();
    print_r($report);
});
Route::group(array('prefix' => 'larafuse'), function () {
    Route::get('/test', function () {
        return Fuse::dsQuery('Product', 1, 0, ['Id' => '%'], ['Id', 'ProductName']);
    });
    Route::get('fetch/rowcount', function () {
        return Fetch::getRowCount();
    });
    Route::get('fetch/{table?}', 'Sairiz\\Larafuse\\Controllers\\LarafuseController@fetch');
    Route::get('fetchid/{table}/{Id}', 'Sairiz\\Larafuse\\Controllers\\LarafuseController@fetchId');
    Route::get('fetchtable/{table}/{page?}/{continue?}', 'Sairiz\\Larafuse\\Controllers\\LarafuseController@fetchTable');
    Route::get('syncmissing/{table?}', 'Sairiz\\Larafuse\\Controllers\\LarafuseController@syncMissing');
开发者ID:sairiz,项目名称:larafuse,代码行数:32,代码来源:routes.php

示例9: foreach

        $files = File::files($directory);
        if (!empty($files)) {
            foreach ($files as $file) {
                $xml = (array) simplexml_load_file($file);
                $save = $doc->updateMetadata($xml, null, true);
            }
        }
    });
    $servers = Server::all();
    foreach ($servers as $server) {
        /**
         * Pull file from remote servers periodically
         * Depends on each server schedule configuration
         */
        Cron::add($server['jobname'], $server['schedule'], function () use($server) {
            exec('rsync -a -e "ssh -p 2222" ' . $server['hostname'] . '@' . $server['address'] . ':' . $server['directory'] . ' ' . $_ENV['SYNC_DIRECTORY']);
        });
        /**
         * Sync metadata.xsd (push)
         */
        // Cron::add("schema", $_ENV['SCHEMA_SYNC_SCHEDULE'], function() use ($server) {
        //   exec('rsync -a -e "ssh -p 2222" '.$_ENV['SYNC_DIRECTORY'].' '.$server['hostname'].'@'.$server['address'].':public');
        // });
    }
});
/*
|--------------------------------------------------------------------------
| Require The Filters File
|--------------------------------------------------------------------------
|
| Next we will load the filters file for the application. This gives us
开发者ID:rahmanda,项目名称:matome,代码行数:31,代码来源:global.php


注:本文中的Cron::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。