SETUP CRON JOB IN LARAVEL
Cron jobs are useful tool for saving our time by scheduling tasks within your laravel application.
A laravel scheduler (cron) will execute commands within a script by the every minute.
They can be scheduled to do many tasks including sending mail to user, etc.
We will be using the crontab option that is within ubuntu.
Step 1 : Update ubuntu
Update system for latest release of updates by following command.
Step 2 : Install cron package
By default cron package was installed in ubuntu, check with following command.
dpkg -l cron
If you found not install then run following command.
sudo apt-get install cron
Now, check cron package is running or not by the use of following command.
systemctl status cron
Step 3 : Configure the cron job
For laravel we need to configure only one scheduler task, that will be watch on your every task.
Now, run following command for editing / configure cron job
System will ask you about which editor you need to use, we are going to use nano editor, which is easier to use
Step 4 : Set laravel scheduler
Add following line at the end of cron tab.
In below replace your application path.
* * * * * cd /var/www/html &amp;&amp; php artisan schedule:run >> /dev/null 2>&amp;1
Now close nano editor & all done here.