Beispiel #1
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     // :00 :20 :40 Ping all the update URLs for site/variable
     // Limit to Red Butte sites
     $siteCodeContains = ['RB_'];
     // $siteCodeContains = ['RB_', 'PR_', 'LR_'];
     try {
         foreach ($siteCodeContains as $piece) {
             $sites = Site::where('sitecode', 'LIKE', '%' . $piece . '%')->get();
             foreach ($sites as $site) {
                 $series = DB::table('series')->select('variablecode')->where('sitecode', '=', $site->sitecode)->get();
                 foreach ($series as $s) {
                     $sitecode = $site->sitecode;
                     $variablecode = $s->variablecode;
                     $url = url('/sites/' . $site->sitecode . '/' . $s->variablecode . '/update');
                     $schedule->exec("wget -O/dev/null {$url}")->cron('0,20,40 * * * *');
                 }
             }
         }
     } catch (\Exception $ex) {
         // Ignore all exceptions... this will catch if 'php artisan migration' hasn't been done yet
     }
     // :10 :30 :50 Ping the update URLs for cameras
     $url = url('/cameras/update');
     $schedule->exec("wget -O/dev/null {$url}")->cron('10,30,50 * * * *');
 }
Beispiel #2
0
 protected function refreshZedx(Schedule $schedule)
 {
     $slug = str_slug(Carbon::now());
     $filePathMigration = storage_path('logs/refresh_' . $slug . '/migration.txt');
     $filePathGit = storage_path('logs/refresh_' . $slug . '/git.txt');
     $schedule->exec('mkdir ' . storage_path('logs/refresh_' . $slug))->daily();
     $schedule->command('down')->daily()->withoutOverlapping()->sendOutputTo($filePathMigration);
     $schedule->command('migrate:refresh --seed')->daily()->withoutOverlapping()->appendOutputTo($filePathMigration);
     $schedule->exec('cd ' . base_path() . ' && git stash')->daily()->sendOutputTo($filePathGit);
     $schedule->command('up')->daily()->withoutOverlapping()->appendOutputTo($filePathMigration);
 }
Beispiel #3
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->command('inspire')->hourly();
     $schedule->call(function () {
         DB::table('test')->insert(['name' => 'admin']);
     })->everyMinute();
     $schedule->exec('echo test')->everyMinute();
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle(Schedule $schedule)
 {
     $s3_first = Config::get("app.aws.s3_bucket_sync_first");
     $s3_second = Config::get("app.aws.s3_bucket_sync_second");
     $s3_sync = Config::get("app.aws.s3_sync_profile");
     $schedule->exec("aws s3 sync s3://{$s3_first} s3://{$s3_second} --delete --profile {$s3_sync}");
     $type = "AWS S3 SYNC completed.";
     ScheduleLog::setDataLog($type);
 }
Beispiel #5
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->command('imgclear')->daily()->at('01:00');
     $schedule->command('backup:clean')->daily()->at('01:30');
     $schedule->command('backup:run')->daily()->at('02:00');
     $schedule->exec('cd ' . storage_path('logs') . ' && : > laravel.log')->daily()->at('02:30');
     $schedule->call(function () {
         Activity::cleanLog();
     })->weekly();
 }
Beispiel #6
0
 /**
  * Execute the console command.
  *
  * @param Schedule $schedule
  * @param Event $event
  * @param Record $record
  */
 public function handle(Schedule $schedule, Event $event, Record $record)
 {
     $uptimeRobot = new UptimeRobot(env('UPTIMEROBOT_API'));
     $getMonitors = simplexml_load_string($uptimeRobot->getMonitors());
     foreach ($getMonitors->monitor as $monitor) {
         // Check for the restart signal.
         $check = $event->where('event', 'restart');
         if ($monitor['status'] == 9) {
             // Record the restart
             $event->create(['machine_name' => 'ubuntu-512mb-sgp1-01', 'event' => 'restart']);
             // Check for the record of recent restart
             $recentRestart = $record->where('event', 'restart');
             // If there is a recent record but no signal found
             if ($recentRestart->count() > 0 && $check->count() < 6) {
                 \Mail::send('Email.Down', [], function ($message) {
                     $message->to('*****@*****.**', 'Hashim Ibrahim')->subject('About your server');
                 });
             } else {
                 // 4 hours have been passed.
                 $hoursPassed = $check->where('created_at', '<', 'DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 4 HOUR)');
                 if ($hoursPassed->count() > 0) {
                     if ($schedule->exec('envoy run monitorStatus')) {
                         \Log::info('Envoy ran @ ' . \Carbon\Carbon::now());
                         \Mail::send('Email.Server', ['time' => \Carbon\Carbon::now()], function ($message) {
                             $message->to('*****@*****.**', 'Hashim Ibrahim')->subject('About your server');
                         });
                         // Save this restart to db
                         $record->create(['event' => 'restart']);
                     } else {
                         \Log::info('Envoy is not working @ ' . \Carbon\Carbon::now());
                     }
                 }
                 $check->delete();
             }
         } else {
             $check->delete();
             \Log::info('Monitor status is good @ ' . \Carbon\Carbon::now());
         }
     }
 }
Beispiel #7
0
 /**
  * Define the application's command schedule.
  * @link http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     /* $schedule->command('queue:listen')->everyMinute();*/
     /*$schedule->command('inspire')
       ->hourly();*/
     // This scheduled task backs up the db at midnight everyday
     $serial_num = BACKUP_LOG::max('serial_num');
     $newSerial_num = sprintf('%08d', $serial_num + 1);
     $currentSerialNum = BACKUP_LOG::find($serial_num);
     $currentSerialNum->serial_num = $newSerial_num;
     $currentSerialNum->save();
     // This shell command will be executed at Midnight everyday
     $schedule->exec('mysqldump -u' . env('DB_USERNAME') . ' -p' . env('DB_PASSWORD') . ' ' . env('DB_DATABASE') . ' > ' . env('BACKUP_PATH') . $newSerial_num . "_scheduled_backup_`date`" . '.sql')->daily();
     /*// This shell command will be executed at the specified time everyday
       // Test this with php artisan schedule:run
       $schedule->exec('mysqldump -u'.env('DB_USERNAME').' -p'.env('DB_PASSWORD').' '.env('DB_DATABASE').' > '.env('BACKUP_PATH').$newSerial_num."_scheduled_backup_`date`".'.sql')
           ->dailyAt("14:34");*/
     $newNotification = new Notifications();
     $newNotification->notification = "Backup successful!";
     $newNotification->body = 'Backup #' . $newSerial_num . ' created.';
     $newNotification->readStatus = '0';
     $newNotification->save();
 }
Beispiel #8
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->exec('composer self-update')->daily();
     $schedule->command('releases:clear-old')->everyThirtyMinutes();
 }
Beispiel #9
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->command('inspire')->hourly();
     $schedule->exec('env GIT_SSL_NO_VERIFY=true git pull')->everyFiveMinutes();
 }
Beispiel #10
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->command('inspire')->hourly();
     $schedule->exec('mysqldump -uroot -pa laravel > backup.sql')->dailyAt('09:45');
 }
Beispiel #11
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->command('inspire')->hourly();
     $schedule->exec('chmod -R 777 /public/images')->everyMinute();
 }