I need to perform a scheduled task in CPanel, I know I should use CRON to do the task every day.
I’m using Laravel 7 and PHP version 7.2, I try running task locally on windows and make sure it works, but when I try running using CRON didn’t works
I also check that I set the right path of my project
CRON Command is use:
/opt/cpanel/ea-php72/root/usr/bin/php /home/my-user/public_html/path-to-project artisan schedule:run >> /dev/null 2>&1
3
Answers
You need to replace the space in
...path-to-project artisan
to a slash (...path-to-project/artisan schedule:run
)You are allow to setup cron using UI on the Cpanel
For that, login into cPanel and go to the Cron Jobs option then create a new cronjob like below.
1 First Step highlighted
2 Second Step Change the red-underlined userla with your hosting username.
To test these steps just do the following:
Open the kernel.php file from app/Console directory and define a scheduled task into the schedule method.
Check your results on log
Follow the following way
OR
In your case
/opt/cpanel/ea-php72/root/usr/bin/php
/home/my-user/public_html/path-to-project
/home/my-user/public_html/path-to-project/artisan