dongwen6743 2016-09-27 10:38
浏览 210

Laravel Cron Job没有运行命令

I am working with Laravel 5.3 , on an Digital Ocean LEMP Stack droplet (ubuntu server).

I am trying to create a cron job that will my command every 15 minutes, It looks like the cronjob on the server is running , but the command is not getting executed.

Now if manually do php artisan import:data from the server terminal, it runs perfectly.

This is in my crontab -e:

* * * * * php /var/www/itom/artisan schedule:run> /dev/null 2>&1

On the laravel docs it shows this:

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

So im sure this is correct.

Inside of app/console/kernel.php:

protected function commands()
{
    require base_path('routes/console.php');
}

protected $commands = [
    \App\Console\Commands\ImportData::class,
];

protected function schedule(Schedule $schedule)
{
    $schedule->command('import:data')->cron('*15/ * * * * *');
}

Inside my app/console/commands/ImportData.php:

use App\Import;

class ImportData extends Command
{

protected $signature = 'import:data';

protected $description = 'Imports page100.txt probe data';

public function __construct()
{
    parent::__construct();
}

public function handle()
{
    $import = new Import;
    $import->start();
}

I don't understand why this isn't working with cronjob, but it's working when I manually run php artisan import:data

  • 写回答

1条回答 默认 最新

  • dtjzpg5313 2016-09-27 11:08
    关注

    In your schedule method you have $schedule->command('import:data')->cron('*15/ * * * * *');

    This should be changed to the following: $schedule->command('import:data')->cron('*/15 * * * * *');

    评论

报告相同问题?

悬赏问题

  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动