Overview
Jobs in Magma allow you to schedule recurring tasks for your agent to perform. Using the@job decorator, you can define tasks that run on a specified schedule using cron syntax.
If a job is not declared as static, it will be scheduled to run on the agent’s instance, for every session of the agent. Learn more about sessions
Basic Implementation
Here’s a simple example of implementing a job:Job Scheduling
Jobs use standard cron syntax for scheduling:Advanced Job Configuration
Jobs can accept configuration options:Static Jobs
Some jobs don’t need to access the agent’s context, and don’t need to be run on every session of the agent. You can declare them as static methods:Common Use Cases
Data Synchronization
Maintenance Tasks
Report Generation
Agent completions
Best Practices
-
Error Handling
-
Resource Management
- Consider server load during job scheduling
- Avoid overlapping job executions that modify the same resources
- Implement proper cleanup in case of failures
-
Monitoring
- Log job execution results
- Track execution time
- Monitor success/failure rates
Limitations
- Jobs must be async methods
- Maximum execution time is 5 minutes
- Timezone must be a valid IANA timezone string