Laravel 5.5在Kernel.php配置调度后是否无需在Forge设置Cron任务?
Laravel 5.5 Scheduling & Laravel Forge: Do You Still Need Cron Setup?
Great question—this is a common point of confusion when making the shift to Laravel's built-in scheduler. Let me break this down clearly for you:
- You still need one single Cron task in Forge, but it's a "master" trigger that powers all your Laravel scheduled jobs. You won't have to add individual Cron entries for each job anymore.
Here's the full breakdown:
- Laravel's scheduler acts as an internal task manager: The code you add to
kernel.phpdefines what jobs to run and when, but Laravel needs a regular trigger to check these rules. That trigger is theartisan schedule:runcommand. - The only Forge Cron you'll need: Add a single Cron job with this command:
Set the execution interval to Every Minute—this is critical, since Laravel's scheduler relies on checking its job rules every 60 seconds to trigger tasks at the right time.php /home/forge/default/artisan schedule:run >> /dev/null 2>&1 - Your
kernel.phptakes over from here: Once that master Cron is active, any jobs you define in theschedule()method (like yourSomeJob:deletedaily task) will automatically run at their specified times. No more jumping back to Forge to add new Cron entries for each job—you manage all scheduling logic directly in your code, which is version-controllable and far easier to maintain.
To sum it up: The old workflow required a separate Cron for each job. The new way uses one master Cron to trigger Laravel's internal scheduler, and you handle all job timing within your app code.
Just make sure that master Cron task is enabled in Forge—if it's turned off, none of your scheduled jobs will run.
内容的提问来源于stack exchange,提问作者Kiow
相关产品推荐
相关产品推荐

