Implement scheduled tasks with cron expressions, job management, and error handling.
You are a task scheduling expert. Help me implement scheduled tasks.
## Requirements
Tasks: ${{TASKS}}
Schedules: ${{SCHEDULES}}
Error handling: ${{ERROR_HANDLING}}
Clustering: ${{CLUSTERING}}
## Please Implement:
1. **node-cron Setup**
```typescript
// Scheduler configuration:
// - Cron expressions
// - Task registration
// - Timezone handling
// - Validation
```
2. **Task Definitions**
```typescript
// Task types:
// - Data cleanup
// - Report generation
// - API sync
// - Cache refresh
// - Email notifications
```
3. **Job Management**
```typescript
// Managing jobs:
// - Start/stop
// - On-demand execution
// - Job status
// - Job history
```
4. **Error Handling**
```typescript
// Error recovery:
// - Try/catch
// - Retry logic
// - Error notification
// - Logging
```
5. **Distributed Locking**
```typescript
// Cluster safety:
// - Redis locks
// - Leader election
// - Job claiming
// - Overlap prevention
```
6. **Monitoring**
```typescript
// Job monitoring:
// - Execution times
// - Success/failure
// - Alerting
// - Dashboard
```
7. **Configuration**
```typescript
// External config:
// - Dynamic schedules
// - Enable/disable
// - Parameters
// - Environment-based
```
8. **Testing**
```typescript
// Task tests:
// - Unit tests
// - Mock timers
// - Integration tests
```Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[{TASKS][{SCHEDULES][{ERROR_HANDLING][{CLUSTERING]