Webuzo环境下Laravel Cron Job无法每分钟执行的问题排查求助
Hey there! Let's dig into why your read:hardware command isn't running every minute as expected. Since the command works when you run it manually via SSH, the issue is almost definitely with how your Cron Job is configured in Webuzo—not the Laravel code itself. Here's a step-by-step breakdown to fix this:
1. Make sure you're running Laravel's scheduler (not the command directly)
Laravel's scheduled tasks rely on the schedule:run artisan command to trigger all scheduled jobs. You shouldn't add the read:hardware command directly to Webuzo's Cron. Instead, your Cron Job needs to execute the scheduler every minute.
Your Cron command should look like this (replace placeholders with your actual paths):
/usr/bin/php /home/your_username/your_project_path/artisan schedule:run >> /dev/null 2>&1
- To find your correct PHP path: Run
which phpin SSH and use that output. - Replace
/home/your_username/your_project_path/with the full path to your Laravel project's root folder (where theartisanfile lives).
2. Verify Cron timing settings
Double-check that your Webuzo Cron Job uses the correct time schedule:
- The timing fields should be
* * * * *(five asterisks), which means "run every minute of every hour, every day, every month, every weekday." - If any field is set to a specific number (e.g.,
0 * * * *), it will only run once an hour—so fix that immediately.
3. Check Cron execution logs for errors
To debug what's going wrong, redirect the Cron output to a log file instead of /dev/null. Modify your Cron command to:
/usr/bin/php /home/your_username/your_project_path/artisan schedule:run >> /home/your_username/cron_laravel.log 2>&1
Wait 2-3 minutes, then check the cron_laravel.log file via SSH or Webuzo's file manager. Look for:
- Path errors (e.g., "Could not open input file: artisan")
- Permission issues (e.g., "Permission denied")
- Laravel-specific errors (e.g., missing dependencies, configuration issues)
4. Fix file permissions
Ensure the user running the Cron Job (usually your Webuzo account user) has proper permissions:
- Give the
artisanfile execution rights:chmod +x /home/your_username/your_project_path/artisan - Make sure the storage and bootstrap/cache directories are writable by the Cron user. You can run:
chmod -R 755 /home/your_username/your_project_path/storage chmod -R 755 /home/your_username/your_project_path/bootstrap/cache
5. Confirm your command is registered in Laravel
Just to be safe, verify that your read:hardware command is properly registered:
- Open
app/Console/Kernel.phpand check if your command class is listed in the$commandsarray. - Run
php artisan listin SSH—you should seeread:hardwarelisted under the available commands. If not, double-check your command's setup.
6. Test the full Cron command manually
Copy the exact command you entered in Webuzo's Cron Job and run it directly in SSH. This will let you see immediate feedback:
- If it outputs something like
Running scheduled command: '/usr/bin/php' 'artisan' read:hardware > '/dev/null' 2>&1 &, that means the scheduler found and ran your job. - If you get an error, fix it before re-saving the Cron Job in Webuzo.
内容的提问来源于stack exchange,提问作者Wahidul Alam

