0

I have a Laravel scheduler configured to run every 6 hours. Based on the schedule, it should have already executed, but I don’t see any expected results or changes from it.

I also added a logger() call inside the scheduler to verify if it’s being triggered, but after checking the logs, there’s no log output at all.

Has anyone experienced this issue before?
What should I check to ensure that the Laravel scheduler is actually running?

<?php namespace App\Console\Commands; use App\Models\Booking; use Illuminate\Console\Command; use Illuminate\Support\Facades\Log; class ExpireBookings extends Command { protected $signature = 'expire:bookings'; protected $description = 'Command description'; public function handle() { Log::info('[ExpireBookings] Cronjob started at '.now()); $expired = Booking::where('status', 'pending') ->where('expired_at', '<', now()) ->update(['status' => 'expired']); Log::info("[ExpireBookings] Total bookings expired: {$expired}"); } } 

Additional Info:

  • Laravel version: 11

  • My scheduler is running well in local environment

  • Server: AWS EC2

  • Cron is already set with the command:
    * * * * * php artisan schedule:run

Thank you in advance!enter image description hereenter image description here

Every 6 hours my Scheduler running.

1
  • in crontab you have to using wildcard time, like: * * * * * cd /var/www/myapp && php artisan schedule:run >> /dev/null 2>&1 and then set when to run schedule on routes/console.php Commented May 13 at 10:01

1 Answer 1

0

your cron tab is scheduled to run every minute but you should explicitly schedule the command in routes/console.php to run every 6 hours

use Illuminate\Support\Facades\Schedule; Schedule::command('expire:bookings')->everySixHours(); 

Without this, Laravel doesn’t know when to run your custom command, even though the cron tab execute the schedule:run command.

Ref: https://laravel.com/docs/12.x/scheduling

Sign up to request clarification or add additional context in comments.

1 Comment

actually i have explicitly schedule the command in routes/console.php, but i still dont know why it doesnt run well. after i debug on my server, there are that depend to my schedule that require a permission, and my user doesnt have authority for that is the reason why my schedule blocked and it solved already

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.