Scheduled batch jobs
Latest version of Staex supports running application using a specified schedule.
Schedule is either a list of date and time pairs at which you want to run your application or
a list of date and time intervals with specified periods that are used to calculate the actual date and time at which your application runs.
We also added staexctl schedule
command to simplify scheduling applications from the command line.
This is best described by the examples.
# run the application defined in app.yaml on January 1, 2023
staexctl schedule --from 2023-01-01 app.yaml
# run the application defined in app.yaml hourly from January 1, 2023 until January 1, 2024
staexctl schedule --from 2023-01-01 --to 2024-01-01 --every 1h app.yaml
# run the application defined in app.yaml hourly from January 1, 2023 forever
staexctl schedule --from 2023-01-01 --every 1h app.yaml
# run the application defined in app.yaml hourly from January 1, 03:00:00, 2023 forever
staexctl schedule --from 2023-01-01T03:00:00 --every 1h app.yaml
# run the application defined in app.yaml hourly starting from now and forever
staexctl schedule --every 1h app.yaml
You can also specify the same schedule in application YAML file and use staexctl start app.yaml
to run applications.
name: backup
config: !os_exec
command: /bin/cp
args: [-r, /var/lib/mydb, /var/backups]
schedule:
- every: 1h
For the period you can use human-readable suffixes: ms
--- milliseconds, s
--- seconds, m
--- minutes, h
--- hours, d
--- days, w
--- weeks.
Periodic batch jobs are useful to backup the data, rotate logs, cleanup temporary directories, software updates, data staging and much more. Our PostgreSQL how-to guide includes a section about backups.