Cron jobs are useful for manual works & saving our time by scheduling tasks in laravel application.
Laravel's scheduler (cron) will check for 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 your ubuntu for latest packages by following command.
apt-get updateStep 2 : Install cron package
Ubuntu system cron package was already installed, check with following command.
dpkg -l cronIf you found not install then run following command.
sudo apt-get install cronNow, check status of cron package is running or not with the use of following command.
systemctl status cronStep 3 : Configure the cron job
In laravel application only need to configure one scheduler command, that will be check on your every task every minutes.
Now, run following command for editing / configure cron job
crontab -eSystem 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 && php artisan schedule:run >> /dev/null 2>&1Now close nano editor & all done here.