Learn how to setup CRON jobs for task scheduling
Test schedules that end will need to mark as expired. For that, we only need to add a single cron configuration entry to our server that runs the
schedule:runcommand every minute.
To set up the cron job in shared hosting, follow the below steps.
Login to cPanel, go to the Cron Jobs page & add a new con job.
Minute, Hours, Days, Month, Weekday need to be set to *
In the command input field, give the following command.
/usr/local/bin/php path-to-your-project/artisan schedule:run >> /dev/null 2>&1
To set up the cron job, use the following command to edit the crontab file.
$ crontab -e
and add the following line to it.
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
Now reload cron service.
$ sudo service cron reload
Typically, you would not add a scheduler cron entry to your local development machine. Instead, you may use the
schedule:workArtisan command. This command will run in the foreground and invoke the scheduler every minute until you terminate the command:
To run Cron Job on the local machine, go to the application folder and run the following command.
$ php artisan schedule:work
If it is windows, then open the command prompt and run the following command.
C:\xampp\htdocs\app_folder> php artisan schedule:work