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:runtask exists and is enabled (toggle should be on). - Double-check the cron expression tied to it: Laravel requires
schedule:runto 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 includesschedule). - 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 likeNo scheduled commands are ready to run.in Lambda logs.
- Vapor relies on AWS CloudWatch Events to trigger the Lambda function that runs
Validate Lambda Execution Role Permissions
- Make sure the IAM role attached to the schedule Lambda has sufficient permissions: at minimum, it needs
AWSLambdaBasicExecutionRoleto 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.
- Make sure the IAM role attached to the schedule Lambda has sufficient permissions: at minimum, it needs
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:runexecuting. If you don't see any logs for the command, the trigger isn't firing Lambda at all. - If
schedule:rundoes 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.phpare 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.phphas 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).
- Verify methods like
- Even though manual runs work, confirm your task definitions in
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.ymlfor task configuration, double-check that theschedulesection is correctly defined and matches what's in the dashboard.
- Sometimes deployments don't sync task settings properly. Try re-deploying your project with
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
相关产品推荐
相关产品推荐

