Built-in Scheduled Tasks
The daemon runs several scheduled tasks automatically:Disk Usage Calculation
Runs every 60 seconds to track storage usage across all servers.Activity Log Batching
Runs every 5 seconds to collect and send activity logs to the control panel.Server Status Reporting
Runs every 30 seconds to sync server status with the API.Temporary File Cleanup
Runs every 5 minutes to remove old temporary files.Creating Custom Scheduled Tasks
You can create custom scheduled tasks using the daemon’s scheduler API:Advanced Job Configuration
Create jobs with custom settings:Job Management
Enable/Disable Jobs
Cancel a Job
View Job Statistics
One-Time Delayed Tasks
Schedule a task to run once after a delay:Use Cases
Automated Backups
Resource Monitoring
Log Rotation
Best Practices
Keep tasks lightweight
Keep tasks lightweight
Scheduled tasks run on the main event loop. Avoid blocking operations or long-running synchronous code.
Handle errors gracefully
Handle errors gracefully
Jobs that panic will have their failures recorded in statistics. Always wrap task logic in proper error handling.
Use appropriate intervals
Use appropriate intervals
Don’t schedule tasks too frequently. For most operations, intervals of 30 seconds or more are sufficient.
Monitor job statistics
Monitor job statistics
Regularly check job statistics to identify tasks that are failing or taking too long to complete.