Checking Scheduler Status
List All Scheduled Tasks
Use thescheduler:list command to verify your schedules are registered:
Filter by Tag
List schedules for a specific tag:Common Issues
Scheduler not running tasks
Scheduler not running tasks
Symptoms: Tasks are registered but never execute.Possible causes and solutions:
-
Scheduler worker not started
-
Provider not registered
Verify your
adonisrc.tsincludes the provider: -
Preload file not configured
Check that the preload file is registered:
-
Task is disabled
Check if the schedule is skipped:
-
Wrong tag
If running with a specific tag, ensure your schedule has the same tag:
Tasks running multiple times
Tasks running multiple times
Symptoms: The same task executes more than once at each scheduled time.Possible causes and solutions:
-
Multiple scheduler workers running
Check if you have multiple instances:
Stop duplicate processes and ensure only one worker is running per tag.
-
Schedule registered multiple times
Verify your
start/scheduler.tsdoesn’t register the same schedule twice: -
Using decorator without proper setup
If using
@scheduledecorator, ensure the command is properly exported and loaded.
Tasks not preventing overlap
Tasks not preventing overlap
Symptoms: Long-running tasks execute concurrently despite using Check the logs:If you see this warning, overlap prevention is working correctly. The task is being skipped because the previous execution is still running.
withoutOverlapping().Solution:Verify the overlap prevention is configured correctly:The
expiresAt parameter should be longer than your task’s expected execution time.Decorator schedules not working
Decorator schedules not working
Symptoms: Commands with
@schedule decorator don’t execute.Possible causes and solutions:-
Commands not loaded
Ensure your commands are registered in
adonisrc.ts: -
Scheduler not booted
The scheduler must call
boot()to load decorated commands: -
Decorator syntax error
Verify decorator usage:
Timezone issues
Timezone issues
Symptoms: Tasks run at unexpected times.Solution:
-
Verify timezone configuration:
-
Check server timezone:
-
Use IANA timezone names:
Memory leaks
Memory leaks
Symptoms: Scheduler process memory usage grows over time.Possible causes and solutions:
-
Tasks not cleaning up resources
-
Accumulating data in memory
-
Monitor memory usage
Tasks failing silently
Tasks failing silently
Symptoms: Tasks stop working without any visible errors.Solution:
-
Check logs for errors
The worker logs errors by default:
-
Use lifecycle hooks for monitoring
-
Enable debug logging
Debugging Tips
Enable Debug Mode
Increase logging verbosity to debug issues:start/scheduler.ts
Verify Cron Expression
Test your cron expressions using online tools:- crontab.guru - Cron expression editor
- crontab.cronhub.io - Cron expression tester
Test Schedules Immediately
Run tasks immediately for testing:Check Schedule Configuration
Inspect schedule configuration programmatically:Performance Issues
Scheduler consuming too much CPU
Scheduler consuming too much CPU
Possible causes:
-
Too many schedules with high frequency
-
Heavy synchronous operations
- Reduce schedule frequency
- Use asynchronous operations
- Optimize task logic
- Consider running fewer tasks per worker
Watch mode restarting too often
Watch mode restarting too often
Symptoms: The scheduler restarts constantly in watch mode.Solution:The watch mode ignores
node_modules, .git, and build directories by default. If it’s restarting too often, check for:-
Files being generated in watched directories
- Log files
- Temporary files
- Build artifacts
-
Database files in project root
- SQLite databases
- Session files
.gitignore or move them outside the project directory.Getting Help
If you’re still experiencing issues after trying these troubleshooting steps:Gather Information
Collect this information before asking for help:-
Environment details:
-
Scheduler configuration:
-
Error messages:
- Full error stack traces
- Relevant log output
-
Minimal reproduction:
- Simplified code that reproduces the issue
Support Channels
GitHub Issues
Report bugs or request features
AdonisJS Discord
Get help from the community
Frequently Asked Questions
Can I run the scheduler as part of my HTTP server?
Can I run the scheduler as part of my HTTP server?
No, the scheduler should run as a separate process. Starting it alongside your HTTP server would impact web request performance and could lead to duplicate task execution in multi-instance deployments.Run it separately:
How do I run scheduled tasks in tests?
How do I run scheduled tasks in tests?
You can manually trigger scheduled tasks in tests:
Can I use the scheduler with Redis for distributed locking?
Can I use the scheduler with Redis for distributed locking?
The built-in overlap prevention uses in-memory locking (async-lock). For distributed systems with multiple servers, you’ll need to implement custom locking using Redis or another distributed lock manager:
How many tasks can I schedule?
How many tasks can I schedule?
There’s no hard limit, but consider:
- Each schedule creates a node-cron task
- High-frequency schedules (every second) consume more resources
- Memory usage scales with the number of schedules
- 100 schedules: Minimal impact
- 1,000 schedules: May need monitoring
- 10,000+ schedules: Consider alternative architecture
Can I dynamically add/remove schedules at runtime?
Can I dynamically add/remove schedules at runtime?
Yes, you can add schedules programmatically:However, removing schedules at runtime is not supported. The scheduler loads all schedules on boot and keeps them for the entire process lifecycle. To modify schedules, restart the scheduler worker.
Next Steps
Configuration
Learn about advanced configuration options
API Reference
Explore the complete API documentation