0

I am working on laravel scheduling everything is working fine. My schedule code is below:

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();
}

Now after that, I run the command the PHP artisan schedule: run it's saving the data in word table.

Now my question is that after one minute it's not saving again... I have researched on google and try many references it's not working at all.

My project is in E Drive path is E:/xammp/htdocs/testtutorials/phpmonitor and I run below command and it's not working

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

its giving me below error:

The system cannot find the path specified.

enter image description here

Salim Djerbouh
  • 10,719
  • 6
  • 29
  • 61
user
  • 51
  • 9

1 Answers1

0

The command you have above is a UNIX-style command. Windows is different in the following aspects:

  1. Paths do not start with a /, they start with a drive letter.
  2. The /dev/null device does not exist. The Windows equivalent is nul.

So, change your command to the following:

php E:\xampp\htdocs\testtutorials\phpmonitor\artisan schedule:run >nul 2>&1
ooa
  • 463
  • 2
  • 8
  • command seems to be working fine but its not saving data in databbase after one minute? – user Oct 03 '19 at 11:05
  • this is same as php artisan schedule:run – user Oct 03 '19 at 11:05
  • its saving data only when i run command i want to save after everyminute without running the command – user Oct 03 '19 at 11:07
  • You're supposed to put the above command into the task scheduler (on Windows), or the crontab (on UNIX-like systems), not run it manually (though you can run manually to test). The framework itself will not handle the repeated runs for you. – ooa Oct 03 '19 at 11:09
  • so what about cpanel i will add command in cron jobs section in cpanel so after that where i found Task scheduler? really confusing can you elaborate? – user Oct 03 '19 at 11:11