Scheduled Tasks and CRON Jobs
Zerops provides a convenient way for managing scheduled tasks through CRON jobs, configured directly in your zerops.yml
file. These tasks can be scheduled to run on single or multiple containers with granular timing control.
Basic Configuration​
Cron jobs are defined in the run.crontab
section of your zerops.yml
. Each job requires two essential parameters:
- command: The command to execute
- timing: The CRON schedule expression
This example logs the current timestamp every hour.
For comprehensive configuration options and examples, refer to our CRON configuration guide.
Common Implementation Patterns​
Laravel Scheduler​
To run Laravel's scheduler, configure it to execute every minute:
Cleanup Tasks​
Execute maintenance tasks on all containers:
Multiple Jobs​
Configure multiple scheduled tasks within a single service:
Best Practices​
-
Log Output: Implement comprehensive logging for debugging and monitoring:
-
Working Directory: Always specify
workingDir
for Laravel commands to ensure they are executed from the correct location. -
Container Selection: Use
allContainers: true
carefully to avoid duplicate operations in a multi-container setup. -
Timing Considerations: Schedule intensive tasks during off-peak hours.
Monitoring​
Enable detailed scheduler logging in your .env
: