laravel scheduler run
php artisan schedule:list
php artisan schedule:run
laravel scheduler run
php artisan schedule:list
php artisan schedule:run
laravel 8 scheduler
// app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
$schedule->call(function () {
DB::table('tbl_logs')->where('created_at', '<=', Carbon::now()->toDateTimeString())->delete();
})->monthly()->evenInMaintenanceMode(); // this query will run every month, read official documentation for detail
}
// run this on your terminal:
php artisan shedule:work
// how about when my laravel project was deployed on live server / web hosting?
// it's not funny when i must connect SSH to server many times just for run that command.
// here my solution:
// 1. connect to your server
// 2. type:
crontab -e
// add these following line:
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
// save and done.
// read official documentation about "scheduling" for more detail
laravel run schedule locally
php artisan schedule:work
Laravel Scheduler
$schedule->call(function () {
DB::table('users')->whereYear('last_login_at','<',date('Y')-1)->delete();
})->daily();
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us