mercredi 7 juin 2017

Why can I not open my crontab? Laravel 5 task schedular

I just started working on an artisan command which outputs "hello" every minute with the Laravel task schedular.

My command 'php artisan DeleteInActiveEvents:deleteevents' outputs what is should in the terminal: "hello".

My Command:

class deleteInActiveEvents extends Command
{
/**
 * The name and signature of the console command.
 *
 * @var string
 */
protected $signature = 'DeleteInActiveEvents:deleteevents';

/**
 * The console command description.
 *
 * @var string
 */
protected $description = 'Command description';

/**
 * Create a new command instance.
 *
 * @return void
 */
public function __construct()
{
    parent::__construct();
}

/**
 * Execute the console command.
 *
 * @return mixed
 */
public function handle()
{
  echo "hello";
}

My Kernel.php

class Kernel extends ConsoleKernel
{
/**
 * The Artisan commands provided by your application.
 *
 * @var array
 */
protected $commands = [
   \einkdisplay\Console\Commands\DeleteInActiveEvents::class
];

/**
 * Define the application's command schedule.
 *
 * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
 * @return void
 */
protected function schedule(Schedule $schedule)
{
  $schedule->command('DeleteInActiveEvents:deleteevents')->everyMinute();
}

/**
 * Register the Closure based commands for the application.
 *
 * @return void
 */
protected function commands()
{
    require base_path('routes/console.php');
}

So everything is still working at this point. But I want to do this command every minute. When I run php artisan schedule:run it is not running the command. The laravel docs say that I need to add:

          • php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1

to my crontab. But when I use crontab -e in the terminal I'm not getting my crontab and I cannot add this line of code. Probably a very noob question but I can't figure it out. Some help in the right direction would be much appreciated!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire