How to Run the Laravel 12 Scheduler on Hostinger

What the Laravel Scheduler Is

Laravel’s task scheduler lets you define scheduled jobs inside your application instead of managing multiple cron entries. You register all scheduled tasks in one place, and a single cron job triggers Laravel every minute to decide what should run.


Step 1: Create the Cron Job on Hostinger

On Hostinger, the scheduler is triggered via a cron job that runs every minute.

  1. Log in to hPanel
  2. Go to Advanced → Cron Jobs
  3. Create a new cron job
  4. Set the schedule to run every minute (* * * * *)
  5. Use the following command:
/usr/bin/php /home/randomuser/domains/mydomain.com/public_html/artisan schedule:run >> /dev/null 2>&1

Replace randomuser and mydomain.com with your actual account username and domain.

This command ensures Laravel’s scheduler is executed once per minute. Laravel itself decides which tasks are due to run.


Step 2: Configure Scheduled Commands in Laravel

All scheduled tasks are defined in:

app/Console/Kernel.php

Inside the schedule method, you can register commands, jobs, or closures.

Example:

use Illuminate\Console\Scheduling\Schedule;

protected function schedule(Schedule $schedule): void
{
    $schedule->command('emails:send')->daily();
    $schedule->command('reports:generate')->hourly();
}

Laravel evaluates this schedule every time schedule:run is executed by the cron job and only runs tasks that are due.


Step 3: Verify Execution

  • Check storage/logs/laravel.log for errors
  • Add logging or notifications inside scheduled commands if needed
  • You only need one cron job regardless of how many scheduled tasks you define

Key Notes

  • Do not create multiple cron jobs for each task
  • Always use absolute paths on shared hosting
  • Ensure the PHP binary path (/usr/bin/php) matches your Hostinger setup

Once the cron job is active, your Laravel scheduler will run reliably on Hostinger.