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

Laravel Vapor定时任务未按计划执行问题排查咨询

Troubleshooting Laravel Vapor Scheduled Tasks Not Running

Hey there, let's walk through the key areas to investigate when your Laravel Vapor scheduled tasks aren't firing as expected—since manual runs work, the core issue is almost certainly that the artisan schedule:run command isn't being triggered on schedule. Here's what to check step by step:

  • Verify Vapor Dashboard Task Configuration

    • Log into your Vapor dashboard, navigate to your project, and head to the Tasks tab.
    • Confirm the schedule:run task exists and is enabled (toggle should be on).
    • Double-check the cron expression tied to it: Laravel requires schedule:run to run every minute, so the correct cron is * * * * *—make sure there are no typos or missing asterisks.
    • Ensure the task is assigned to the correct environment (don't accidentally have it configured for a staging environment when you're testing production).
  • Check AWS CloudWatch Events Trigger (Under the Hood)

    • Vapor relies on AWS CloudWatch Events to trigger the Lambda function that runs schedule:run. Go to the AWS Console, find the Lambda function associated with your Vapor schedule (name usually includes schedule).
    • Look at the Triggers tab to confirm the CloudWatch Events rule exists and is enabled.
    • Match the CloudWatch Events cron expression to what's set in Vapor—sometimes sync issues can cause mismatches.
    • Try manually triggering the CloudWatch Events rule to see if Lambda executes schedule:run. Even if no tasks are due, you should see a log entry like No scheduled commands are ready to run. in Lambda logs.
  • Validate Lambda Execution Role Permissions

    • Make sure the IAM role attached to the schedule Lambda has sufficient permissions: at minimum, it needs AWSLambdaBasicExecutionRole to write logs to CloudWatch (without this, you won't see any error logs at all).
    • If your tasks interact with other AWS services (like S3), confirm the role has policies allowing those actions—missing permissions could silently fail the task trigger.
  • Dig Into Detailed CloudWatch Logs

    • Don't rely solely on the Lambda CLI logs—head to the CloudWatch Logs Console, find the log group for your schedule Lambda, and review all log entries.
    • Look for any trace of schedule:run executing. If you don't see any logs for the command, the trigger isn't firing Lambda at all.
    • If schedule:run does appear in logs but your tasks don't run, check for messages like Skipping command—this might indicate your task's time conditions (like timezone or cron rules) aren't aligned as expected.
  • Double-Check Laravel Task Schedule Syntax

    • Even though manual runs work, confirm your task definitions in App\Console\Kernel.php are correct:
      • Verify methods like ->everyMinute() or ->dailyAt('08:00') are used properly.
      • Check timezone settings: Vapor defaults to UTC, so if your tasks are scheduled for local time, ensure config/app.php has the correct timezone, or use ->timezone('Asia/Shanghai') directly on the task.
      • Rule out issues with ->withoutOverlapping() (unlikely if manual runs work, but worth confirming the lock mechanism isn't stuck).
  • Ensure Vapor Configuration Syncs Correctly

    • Sometimes deployments don't sync task settings properly. Try re-deploying your project with vapor deploy, or manually save the task configuration in the Vapor dashboard (even if you don't make changes) to trigger a sync.
    • If you're using vapor.yml for task configuration, double-check that the schedule section is correctly defined and matches what's in the dashboard.
  • Check AWS Region & Timezone Alignment

    • Confirm your Lambda function and CloudWatch Events are in the same AWS region as your Vapor project—cross-region misconfigurations can break triggers.
    • Remember CloudWatch Events uses UTC for cron expressions. If you're scheduling tasks for local time, convert it to UTC first (e.g., 8 AM Beijing time is 0 AM UTC, so cron would be 0 0 * * *).

内容的提问来源于stack exchange,提问作者Mahen Nakar

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.08 09:32:40