I'm trying to use laravel 5.1 scheduler to run a data grabbing commands from twitter and store it in the database. If I put the actual command within the Kernel.php file it runs no worries and gets/inserts the data into the database but when I try put it into an external file to run and just put the command in the Kernel I get this
Running scheduled command: (touch/storage/framework/schedule-4ff51352255727a7381f73c7bd3eb90c; '/Applications/MAMP/bin/php/php5.5.18/bin/php' 'artisan' lookup; rm /storage/framework/schedule-4ff51352255727a7381f73c7bd3eb90c) > /dev/null 2>&1 &
This is my Kernal.php file
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use DB;
use Session;
use Carbon\Carbon;
use Thujohn\Twitter\Facades\Twitter;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
\App\Console\Commands\Inspire::class,
\App\Console\Commands\Scheduled_post::class,
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('lookup')
->everyMinute()
->withoutOverlapping();
}
}
and my command
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
class Lookup extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'Lookup';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Performing user lookup';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$user_lookup = Twitter::getUsersLookup(['screen_name' => 'some_user', 'format' => 'object']);
$social_user = array(
'email' => null,
'screen_name' => $user_lookup[0]->screen_name,
);
DB::table('social_users')->insert( $social_user );
}
}
Testing in MAMP, manually executing php artisan schedule:run
through terminal to test.
Im not sure how to fix this or whats going on?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire