How to create a scheduled task

Asked

Viewed 798 times

0

Guys I’m trying to work with cron for the first time and trying to create a very simple scheduled task.

was looking at the documentation and saw that this command needs to be executed

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

I ran him into the terminal like this:

* * * * * php /var/www/html/mail-with-cron schedule:run >> /dev/null 2>&1

with the directory of my project and then gave a php artisan serve

but he didn’t execute the inspire command

2 answers

0

This is not a command that runs on the terminal. You need to put this command on the cron of your server. To do this run on the terminal crontab -e

A file will be opened. Here yes you put the crontab setting.

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

This will execute all commands defined in the method schedule in app/Console/Kernel.php

protected function schedule(Schedule $schedule)
{
    $schedule->command('inspire')
             ->hourly();
}

-1

The Artisan was missing at the end of the directory, so it looks like this:

* * * * * php /var/www/html/mail-with-cron/artisan schedule:run >> /dev/null 2>&1
  • It’s not a cron command

Browser other questions tagged

You are not signed in. Login or sign up in order to post.