Scheduled Tasks
Automate database maintenance, optimization jobs, and report generation with flexible scheduling options and timezone support.
Creating Maintenance Schedules
Schedule routine maintenance tasks to run automatically during low-traffic periods, ensuring optimal database performance without manual intervention.
Basic Schedule Configuration
{
"name": "Nightly VACUUM ANALYZE",
"description": "Regular vacuum and analyze to maintain statistics",
"database": "prod-api-db-01",
"enabled": true,
"schedule": {
"type": "cron",
"expression": "0 2 * * *",
"timezone": "America/New_York"
},
"task": {
"type": "vacuum_analyze",
"parameters": {
"tables": ["orders", "customers", "products"],
"analyze_only": false,
"verbose": true
}
},
"constraints": {
"max_duration": "2h",
"skip_if_load_above": 70,
"require_replica_healthy": true
},
"notifications": {
"on_success": false,
"on_failure": true,
"channels": ["slack", "email"]
}
}Database Maintenance Tasks
- • VACUUM and ANALYZE operations
- • Index rebuilding and defragmentation
- • Statistics updates
- • Partition management
- • Log cleanup and archival
- • Backup verification
Health Checks
- • Connection pool health verification
- • Replication lag monitoring
- • Disk space checks
- • Configuration validation
- • Backup integrity tests
- • Security audit scans
Recurring Optimization Jobs
Set up automated optimization tasks that continuously improve database performance based on usage patterns and ML recommendations.
Query Optimization Schedule
Automatically identify and optimize slow queries based on real-time analysis.
{
"name": "Weekly Query Optimization",
"schedule": {
"type": "weekly",
"day": "sunday",
"time": "03:00",
"timezone": "UTC"
},
"task": {
"type": "query_optimization",
"parameters": {
"analyze_last_days": 7,
"min_execution_count": 100,
"min_avg_duration_ms": 1000,
"apply_recommendations": true,
"require_approval": true
}
}
}Index Maintenance Schedule
Keep indexes healthy with regular maintenance and optimization.
{
"name": "Monthly Index Optimization",
"schedule": {
"type": "monthly",
"day_of_month": 1,
"time": "02:00",
"timezone": "America/Los_Angeles"
},
"task": {
"type": "index_optimization",
"parameters": {
"rebuild_if_fragmented": true,
"fragmentation_threshold": 30,
"remove_unused_indexes": false,
"update_statistics": true,
"concurrent_mode": true
}
}
}Configuration Tuning Schedule
Automatically adjust database configuration parameters based on workload patterns.
{
"name": "Quarterly Config Review",
"schedule": {
"type": "cron",
"expression": "0 1 1 */3 *",
"timezone": "UTC"
},
"task": {
"type": "config_optimization",
"parameters": {
"analyze_workload_days": 90,
"parameters": [
"shared_buffers",
"work_mem",
"maintenance_work_mem",
"effective_cache_size"
],
"apply_changes": false,
"generate_report": true
}
}
}Report Scheduling
Generate and distribute performance reports, capacity forecasts, and analytics summaries automatically.
Daily Performance Report
{
"name": "Daily Performance Summary",
"schedule": {
"type": "daily",
"time": "08:00",
"timezone": "America/New_York"
},
"report": {
"type": "performance_summary",
"period": "last_24h",
"sections": [
"query_performance",
"resource_usage",
"slow_queries",
"recommendations"
],
"format": "pdf"
},
"distribution": {
"email": [
"[email protected]"
],
"slack": "#database-reports"
}
}Weekly Capacity Forecast
{
"name": "Capacity Planning Report",
"schedule": {
"type": "weekly",
"day": "monday",
"time": "09:00",
"timezone": "UTC"
},
"report": {
"type": "capacity_forecast",
"forecast_days": 90,
"metrics": [
"storage_growth",
"connection_trends",
"cpu_trends"
],
"format": "html"
},
"distribution": {
"email": [
"[email protected]",
"[email protected]"
]
}
}Monthly Executive Summary
{
"name": "Executive Summary",
"schedule": {
"type": "monthly",
"day_of_month": -1,
"time": "17:00",
"timezone": "America/New_York"
},
"report": {
"type": "executive_summary",
"period": "last_month",
"include_cost_analysis": true,
"include_incidents": true,
"format": "pdf"
},
"distribution": {
"email": [
"[email protected]"
]
}
}Custom Analytics Report
{
"name": "Custom Business Metrics",
"schedule": {
"type": "weekly",
"day": "friday",
"time": "16:00",
"timezone": "Europe/London"
},
"report": {
"type": "custom_query",
"queries": [
"top_users_by_queries",
"table_access_patterns",
"api_endpoint_performance"
],
"format": "csv",
"include_charts": true
},
"distribution": {
"email": [
"[email protected]"
],
"s3_bucket": "company-reports"
}
}Report Format Options
PDF Reports
Professional formatted reports with charts and tables, ideal for executives and stakeholders.
HTML Reports
Interactive web-based reports with drill-down capabilities and embedded dashboards.
CSV/JSON Exports
Raw data exports for further analysis in BI tools or custom applications.
Timezone Handling
DB24x7 provides comprehensive timezone support for global teams, ensuring scheduled tasks run at the correct local time regardless of where your databases or team members are located.
Timezone Configuration
{
"schedules": [
{
"name": "US East Coast Maintenance",
"timezone": "America/New_York",
"schedule": {
"time": "02:00",
"description": "Runs at 2 AM Eastern Time"
}
},
{
"name": "Europe Maintenance",
"timezone": "Europe/London",
"schedule": {
"time": "03:00",
"description": "Runs at 3 AM British Time"
}
},
{
"name": "Asia Pacific Maintenance",
"timezone": "Asia/Singapore",
"schedule": {
"time": "04:00",
"description": "Runs at 4 AM Singapore Time"
}
}
]
}Daylight Saving Time
Automatically adjusts for DST transitions to maintain consistent local execution times.
Example: A schedule set for 2:00 AM America/New_York will:
- • Skip the non-existent hour during spring forward
- • Run once during the duplicated hour in fall back
Multi-Region Coordination
Coordinate maintenance windows across global database deployments.
Use Case: Schedule maintenance to run during local off-peak hours:
- • 2 AM for US databases
- • 3 AM for EU databases
- • 4 AM for APAC databases
Best Practice: Use IANA Timezone Names
Always use IANA timezone identifiers (e.g., "America/New_York") instead of abbreviations (e.g., "EST") to ensure correct handling of daylight saving time and historical timezone changes.
Managing Schedules
Enable/Disable
Quickly enable or disable schedules without deleting them.
• Temporarily pause schedules
• Preserve configuration
• Resume with one click
Execution History
View complete history of schedule executions.
• Success/failure status
• Execution duration
• Output logs and errors
Missed Runs
Handle schedules that miss their execution window.
• Run immediately on recovery
• Skip missed executions
• Configurable catch-up behavior
Schedule Conflict Prevention
Prevent overlapping executions and resource conflicts.
{
"concurrency_policy": {
"allow_overlap": false,
"action_on_overlap": "skip",
"max_concurrent_runs": 1
},
"resource_limits": {
"max_cpu_percent": 50,
"max_io_percent": 30,
"priority": "low"
}
}Cron Expression Guide
Common Cron Patterns
| Expression | Description |
|---|---|
| 0 2 * * * | Every day at 2:00 AM |
| 0 */6 * * * | Every 6 hours |
| 0 2 * * 0 | Every Sunday at 2:00 AM |
| 0 2 1 * * | First day of every month at 2:00 AM |
| 0 2 * * 1-5 | Weekdays at 2:00 AM (Monday-Friday) |
| */15 * * * * | Every 15 minutes |
Cron Expression Format
│ ┌───────── hour (0-23)
│ │ ┌─────── day of month (1-31)
│ │ │ ┌───── month (1-12)
│ │ │ │ ┌─── day of week (0-6, Sunday=0)
│ │ │ │ │
* * * * *
Use crontab.guru to validate and understand cron expressions.