Context
You have a Laravel app deployed on a CyberPanel-managed server and you’ve set up cronjobs to run Laravel’s scheduled commands (e.g., php artisan schedule:run
), but the cronjobs don’t execute as expected.
Why Laravel Cronjobs Might Not Run on CyberPanel
- Incorrect cron command or environment path
Laravel commands must be run with correct PHP executable and from the Laravel project root directory. - User permission issues
Laravel Cronjobs must run as the correct user (usually the website owner user, not root). - Cron daemon not running or misconfigured
The system cron service must be active and configured properly. - Wrong PHP version or path in cron command
CyberPanel may have multiple PHP versions installed; cron must use the same PHP as your website. - No output or logging to check errors
Silent failures because cron output is redirected to/dev/null
.
Step-by-Step Fix Guide
Step 1: Confirm PHP path
- SSH into your server as the website owner or root.
- Run:
which php
- Or check the PHP version used by CyberPanel for your site at CyberPanel > Websites > List Websites > PHP version.
- Find the full path of PHP CLI matching that version. It may be something like:
/usr/local/lsws/lsphp74/bin/php
Step 2: Write the correct cronjob command
Your Laravel app is usually at:
/home/yourdomain.com/public_html/
A correct cron entry for Laravel scheduler looks like:
* * * * * /usr/local/lsws/lsphp74/bin/php /home/yourdomain.com/public_html/artisan schedule:run >> /dev/null 2>&1
- Adjust PHP path
/usr/local/lsws/lsphp74/bin/php
to match your PHP version. - Use full path to
artisan
. - The
schedule:run
command triggers all scheduled tasks.
Step 3: Add the cronjob for the correct user
- Login as your website user or root.
- Add the cronjob with:
crontab -e
- Paste the cronjob line from Step 2.
- Save and exit.
Step 4: Check cron service status
- Ensure cron daemon is running:
systemctl status cron
# or
systemctl status crond
- If not running, start it:
sudo systemctl start cron
Step 5: Verify Laravel schedule and commands
- Check
app/Console/Kernel.php
— make sure commands are registered in$commands
array. - Check the
schedule()
method schedules commands properly. - Test the command manually:
/usr/local/lsws/lsphp74/bin/php /home/yourdomain.com/public_html/artisan schedule:run
It should run without error.
Step 6: Debug cron output
To catch errors, modify the cronjob to log output:
* * * * * /usr/local/lsws/lsphp74/bin/php /home/yourdomain.com/public_html/artisan schedule:run >> /home/yourdomain.com/cron.log 2>&1
- Check
cron.log
to see errors or output.
Step 7: Additional tips
- Ensure your
.env
file is correctly configured for production (APP_ENV, DB connections). - If you use queue workers, ensure they are running separately (
php artisan queue:work
or use Supervisor). - File permissions: the user running the cron must have permission to read/write Laravel files and execute PHP.
- Timezone: cron uses server time, verify it matches your Laravel timezone in
config/app.php
.
Summary
Problem Cause | Solution Summary |
---|---|
Wrong PHP path | Use full path to PHP CLI matching your site’s PHP version |
Cron run as wrong user | Add cronjob under correct website user |
Cron service stopped | Start cron service with systemctl start cron |
Laravel commands not registered | Check app/Console/Kernel.php for commands and schedule |
Silent failures | Log cron output to file for debugging |