So here's what happened to me since these solutions are quite correct in term of defining the new Cron job, there was an issue for me that was causing the script to not run, and I'm mentioning to this because at some point, people might confuse if the correct entry is :
/usr/local/bin/php or /usr/bin/php or even php.
So basically I had this working using both above entries, until I moved my project to a new VPS with Cpanel, and script was working, everything was correct except the Cron Job.
So here's the steps to fix the issue.
- Check the server time zone.
I had to set my server time to Asia/Tehran which before setting this my Cron wasn't executing at the correct moment and you can set time zone using WHM, Server time.
Check if Cron job is ran using :
grep "replace with file or whatever you're calling" /var/log/cron
Cron job is running, great, let's check if script is working, so go to the location of the script and run the script, which at this point mine was running a simple php artisan in Laravel directory, and then I've got the real issue.
Your PHP requirement version for version 8 show up.
So in Cpanel when you try to define a version for a domain/sub-domain, you can see above it say, the default PHP version is x.xx and at this point I found out I should change it which in WHM, in Software and then MultiPHP Manager, set the PHP version to desired version that Laravel need to ran.
Defining PHP version in Cpanel isn't enough since Cron is not working like that and it's relying on the default version that's defined in WHM or Server.