phpcronlaravel-8schedule

Cron Job / Schedule Command in Laravel


I am trying to make a command run at a specific time, using cronjobs with Laravel, the command I created is as follows:

$schedule->command('test:message')->timezone('Asia/Kolkata')->dailyAt('17:21');

Now, on the cronjobs tab in cpanel, when I set the job to run at the same time i.e

21  17  *   *   *   /usr/local/bin/php /home/admin/public_html/project_name/admin/artisan test:message >> /dev/null 2>&1

the command does not work, and when I make a change to work it once per minute i.e

*   *   *   *   *   /usr/local/bin/php /home/admin/public_html/project_name/admin/artisan test:message >> /dev/null 2>&1

then it runs the command every minute. All I need is the command to run only at 17:21 every day


Solution

  • The command is incorrect

    *   *   *   *   *   /usr/local/bin/php /home/admin/public_html/project_name/admin/artisan schedule:run >> /dev/null 2>&1
    

    this is the correct command. You should run the schedules and laravel will handle the timezone and the correct time