0

I created job.php at ..\app\commands\

public function fire()  {
    $this->dailyAt('09:00', function(){
    Mail::send('emails.test', array(), function($message) {
             $message->to('address', '')->subject('subject')->attach('path');
         });
    });//end daily
 }

protected function dailyAt($time, callable $callback){
    if(date('H:i', $this->timestamp) === $time) call_user_func($callback);
}

I put 'php artisan cron:run' on command prompt manually, it runs perfectly. How could I schedule this? I know there is something like * * * * *, however, I have no idea how to use of * * * * *

I am using Laravel-4.2

Please Help

Ankur Tiwari
  • 2,762
  • 2
  • 23
  • 40

1 Answers1

0

Basically you want to create a cron job. you can do this by adding the command into a crontab. in cli from the root of your project type crontab -e, and then add your command.

/10 * * * * /usr/bin/php pathto/artisan namespace:command

where /10 * * * * is the time(this will launch at every 10 minutes), /usr/bin/php the location of php cli, and pathto/artisan namespace:command is the location of the command that will be executed. Example:

/10 * * * * /usr/bin/php /var/www/fooproject/artisan cron:run

More info , and something about cronjobs.

Community
  • 1
  • 1
LeviTheOne
  • 105
  • 9