You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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:

  1. Laravel's scheduler acts as an internal task manager: The code you add to kernel.php defines what jobs to run and when, but Laravel needs a regular trigger to check these rules. That trigger is the artisan schedule:run command.
  2. The only Forge Cron you'll need: Add a single Cron job with this command:
    php /home/forge/default/artisan schedule:run >> /dev/null 2>&1
    
    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.
  3. Your kernel.php takes over from here: Once that master Cron is active, any jobs you define in the schedule() method (like your SomeJob:delete daily 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:51:31