Comment on page

Task Scheduling

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:run command every minute.

Setup Cron Job on Shared Hosting

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
Change the path and PHP version according to your hosting.

Setup Cron Job on Cloud VPS

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
Replace the project path with your application path.
Now reload cron service.
$ sudo service cron reload

Run Cron Job on Local Host

Typically, you would not add a scheduler cron entry to your local development machine. Instead, you may use the schedule:work Artisan 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