Here is a schedule example
protected function schedule(Schedule $schedule)
In my case, it’s to daily delete the expired orders
sudo vim /etc/crontab
* * * * * apache cd /var/www/html/yourProjectName && php artisan schedule:run >> /dev/null 2>&1
- Here are the meaning of * * * * * in orders
- What date in a month(1-31)
- What day in a week(0-6)
it represents the user. It’s important here, because if you don’t set it properly, when error occurs as you execute the schedule, the log owner will be the user you set here, which might have authority problem. If you also log other information in other place, and the whole project might not be able to work properly when the log file reject to be written.
cd ray cd /var/www/html/yourProjectName
To where your project is
php artisan schedule:run >> /dev/null 2>&1
Run the Task Scheduling command in your Laravel project
- Here you go!