dongyo7931 2019-07-04 15:56
浏览 375

在后台运行Laravel cron工作 - Laravel 5.8

I have a cron job with Laravel:

    public function handle(){
    $reimport = $this->argument('reimport');

    $lib = new CustomLibrary();

    $lib->importAll();

}

I am calling this in my controller:

Artisan::call('my_command');

or in SSH:

php artisan my_command

Te problem is that in both places the job is not in a background, because it takes more than minute to finish.

Is there way to make that job to run in a background in the controller and in SSH (optional) ?

  • 写回答

1条回答 默认 最新

  • dqpu4988 2019-07-05 07:58
    关注

    To start the Laravel Scheduler itself, we only need to add one Cron job which executes every minute. Go to your terminal, ssh into your server, cd into your project and run this command.

    crontab -e
    

    This will open the server Crontab file, paste the code below into the file, save and then exit.

    * * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1
    

    Do not forget to replace /path/to/artisan with the full path to the Artisan command of your Laravel Application.

    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制