Laravel Scheduling call controller

后端 未结 5 1672
北荒
北荒 2021-01-04 05:23

I work with Laravel Task Scheduling, but I have a problem when I call some method from my controller.

protected function schedule(Schedule $schedule)
{
    $         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-04 05:48

    Directly put this in schedule function in kernel.php file

    $schedule->call('App\Http\Controllers\YourController@function')->everyMinute();

    This will run after every minute

    Note:

    In localhost, you have to run it manually but on the server, you should try this command in your cronjob this will automatically call your controller function after every minute

    php -d register_argc_argv=On /home/iflasity/public_html/foldername /artisan schedule:run > /dev/null 2>&1

    cd /home/iflasity/public_html/foldername && php artisan schedule:run /dev/null 2>&1

提交回复
热议问题