In this post I will show you how to set cronjob in cpanel and run the laravel schedule, Here in this tutorial, I have given a command example, in this command, you need to add your cpanel path from the root. after the command is successfully made we will set in the cpanel cronjob with the requirement of a cronjob schedule.
Cronjob automatically runs after we have set time on it, In cPanel, you can use cron jobs to schedule automated tasks that run at specified intervals. To set up a cron job in cPanel, follow these examples.
Cronjob in cpanel must be required when you want to execute the schedule defined in laravel. The cronjob will fire based on the time set and execute the defined schedule match with the cronjob schedule and execute all artisan commands defined in the kernal.php file.
This is the sample demo command for the in my case and cpanel path. You need to add your project root path in the cronjob command for executing the laravel schedule.
/usr/local/bin/php /home/swapinf1/public_html/artisan schedule:run >> /dev/null 2>&1
See the below example, this cronjob will automatically run each minute.
Every Five Minutes
This cronjob example will run the five minutes schedule of the laravel application.
Every Thirty Minutes
This cronjob example will run the schedule every thirty minutes which is set in the kernel file in the command console.
This cronjob will run every hour, if you set an hour schedule in the laravel app, then this every-hour schedule run the script.
Twice In Day
This cronjob will run Twice per day, which means this cronjob will run every mid-day and midnight.
This cronjob will run every midnight.
Once Per Week
This cronjob example for the run schedule takes every week.
Once Per Month
This cronjob command fires every month, which means it will work one time at the beginning of the month.
Once Per Year
This cronjob example for the run every year, this cronjob will run one time in the year.
We always thanks to you for reading our blogs.
Dharmesh Chauhan(Swapinfoway Founder)