0

我正在研究 laravel 调度一切工作正常。我的日程安排代码如下:

public function handle()
{
    //
    $words = [
        'aberration' => 'a state or condition markedly different from the norm',
        'convivial' => 'occupied with or fond of the pleasures of good company',
        'diaphanous' => 'so thin as to transmit light',
        'elegy' => 'a mournful poem; a lament for the dead',
        'ostensible' => 'appearing as such but not necessarily so'
    ];
    $key = array_rand($words);
    $value = $words[$key];
    $word = new Word;
    $word->word_key = $key;
    $word->word_value = $value;
    $word->save();
    $this->info('Word of the Day saved in table');
}

protected function schedule(Schedule $schedule)
{
    $schedule->command('word:day')->everyMinute();
}

之后,我运行PHP artisan schedule 命令:运行它将数据保存在 word 表中。

现在我的问题是,一分钟后它不再保存......我已经在谷歌上进行了研究并尝试了许多参考它根本不起作用。

我的项目在 E 驱动器路径是E:/xammp/htdocs/testtutorials/phpmonitor并且我在命令下运行但它不工作

* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1
  ----------------------------------------------------------
* * * * * php /E:/xammp/htdocs/testtutorials/phpmonitor/artisan schedule:run >> /dev/null 2>&1

它给了我以下错误:

该系统找不到指定的路径。

在此处输入图像描述

4

1 回答 1

0

您上面的命令是 UNIX 风格的命令。Windows 在以下方面有所不同:

  1. 路径不以 开头/,它们以驱动器号开头。
  2. /dev/null设备不存在。Windows 等效项是nul.

因此,将您的命令更改为以下内容:

php E:\xampp\htdocs\testtutorials\phpmonitor\artisan schedule:run >nul 2>&1
于 2019-10-03T11:01:58.760 回答