7

I've created a command to send automatic emails. When I do homestead ssh and I run php artisan emails.send an email arrives in my mailtrap.io account.

I've added this code to the kernel.php

$schedule->command('emails:send')->everyFiveMinutes();

I've put it at a 5 minute interval, just to make it easier to quickly test it. I've ssh'd into Homestead and performed

php /home/vagrant/Code/soeptime/artisan schedule:run 1>> /dev/null    2>&1

then I exit homestead and I did homestead provision

However, there is nothing in the logs and I still haven't received an email, homestead is now running for more then 15 minutes.

Cquence
  • 81
  • 1
  • 3
  • Today I restarted my homestead and I ran 'php artisan sschedule:run' than cli executed this: 'Running scheduled command: /usr/bin/php5 artisan emails.send > /dev/null 2>&1 &' and I got an email in my mailtrap. What does this mean? It isn't happening automatically? I can only run this once, if I try like 15 minutes later it says 'No scheduled commands are ready to run.' – Cquence Aug 24 '15 at 10:49
  • so, is it already time for soup? :-) – morksinaanab Mar 22 '19 at 02:16

2 Answers2

12

You need to manually edit crontab:

First:

 crontab -e

and then add

* * * * * php /home/vagrant/Code/soeptime/artisan schedule:run
Can Celik
  • 2,050
  • 21
  • 30
  • 1
    Upvoting for "/home/vagrant/" at the start of the path, this seems to be missing from a lot of articles – J Foley Oct 17 '19 at 12:21
8

From the Laravel docs:

Laravel provides a convenient way to schedule Cron jobs by scheduling a single schedule:run Artisan command to be run every minute. The schedule:run command will examine the job schedule defined in your App\Console\Kernel class to determine which jobs should be run.

If you would like the schedule:run command to be run for a Homestead site, you may set the schedule option to true when defining the site:

sites:
   - map: homestead.test
     to: /home/vagrant/code/Laravel/public
     schedule: true 

The Cron job for the site will be defined in the /etc/cron.d folder of the virtual machine.

Ryan
  • 22,332
  • 31
  • 176
  • 357