Reputation: 3185
I have set a cron job
* * * * * php /var/www/html/laravel schedule:run 1>> /var/www/html/log_laravel 2>&1
This is what I have set in app\console\Kernel.php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use App\Http\Controllers\DataController;
class Kernel extends ConsoleKernel
{
protected $commands = [
];
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
DataController::get_data();
})->everyMinute();
}
}
Is that it? In docs there isn't anything else but this is not working.
DataController@get_data
should perfom some updates in database (I can also call this manually by going to http//www.site.com/public/data/get_data
. How can I debug this? I don't have anything in log file in storage/logs
and my log_laravel
for Cron job is empty.
Upvotes: 1
Views: 895
Reputation: 2981
You need to reference the path to artisan.php
script:
* * * * * php /var/www/html/laravel/artisan schedule:run 1>> /var/www/html/log_laravel 2>&1
I do not recommend writing output to any logs, this will run every minute, and will kill your disk space.
Upvotes: 2