scheduled-jobs¶
The scheduled-jobs command lets you manage scheduled sql jobs for your cluster.
More information about automation can be found in the CrateDB documentation.
Tip
Scheduled sql jobs are an easy way to setup sql statements that need to be run in a certain interval to manage your clusters data.
Usage: croud clusters scheduled-jobs [-h] {create,list,logs,delete,edit} ...
clusters scheduled-jobs create¶
Create a scheduled sql job to run at specific times.
Usage: croud clusters scheduled-jobs create [-h] --name NAME --cluster-id
CLUSTER_ID --cron CRON --sql SQL
--enabled ENABLED
[--region REGION]
[--output-fmt {table,wide,json,yaml}]
[--sudo]
Required Arguments¶
- --name
Name of the sql job.
- --cluster-id
Cluster where the job should be run.
- --cron
Cron schedule of the sql job.
- --sql
The sql statement the job should run.
- --enabled
Enable or disable the job.
Optional Arguments¶
- --region, -r
Temporarily use the specified region that command will be run in.
- --output-fmt, --format, -o
Possible choices: table, wide, json, yaml
Change the formatting of the output.
- --sudo
Run the given command as superuser.
Default:
False
Example¶
sh$ croud clusters scheduled-jobs create \
--name test-job \
--cluster-id 8d6a7c3c-61d5-11e9-a639-34e12d2331a1 \
--cron "1 1 * * *" \
--sql "DELETE * FROM TABLE test" \
--enabled True
+----------+---------------+-----------+-------------------+-----------+
| name | id | cron | sql | enabled |
|----------+---------------+-----------+-------------------+-----------|
| test-job | 0EW7SX3ND87DY | 1 1 * * * | DELETE FROM test | TRUE |
+----------+---------------+-----------+-------------------+-----------+
clusters scheduled-jobs list¶
List the scheduled sql jobs for a cluster.
Usage: croud clusters scheduled-jobs list [-h] --cluster-id CLUSTER_ID
[--region REGION]
[--output-fmt {table,wide,json,yaml}]
[--sudo]
Required Arguments¶
- --cluster-id
The cluster of which jobs should be listed.
Optional Arguments¶
- --region, -r
Temporarily use the specified region that command will be run in.
- --output-fmt, --format, -o
Possible choices: table, wide, json, yaml
Change the formatting of the output.
- --sudo
Run the given command as superuser.
Default:
False
Example¶
sh$ croud clusters scheduled-jobs list \
--cluster-id 8d6a7c3c-61d5-11e9-a639-34e12d2331a1
+----------+---------------+-----------+-------------------+-----------+---------------------------+
| name | id | cron | sql | enabled | next_run_time |
|----------+---------------+-----------+-------------------+-----------+---------------------------|
| test-job | 0EW7SX3ND87DY | 1 1 * * * | DELETE FROM test | TRUE | 2024-01-20T01:01:00+00:00 |
+----------+---------------+-----------+-------------------+-----------+---------------------------+
clusters scheduled-jobs logs¶
List the past executions of a scheduled sql job.
Usage: croud clusters scheduled-jobs logs [-h] --job-id JOB_ID --cluster-id
CLUSTER_ID [--region REGION]
[--output-fmt {table,wide,json,yaml}]
[--sudo]
Required Arguments¶
- --job-id
The job id of the job log to be listed.
- --cluster-id
The cluster of which the job log should be listed.
Optional Arguments¶
- --region, -r
Temporarily use the specified region that command will be run in.
- --output-fmt, --format, -o
Possible choices: table, wide, json, yaml
Change the formatting of the output.
- --sudo
Run the given command as superuser.
Default:
False
Example¶
sh$ croud clusters scheduled-jobs logs \
--job-id 0EW7SX3ND87DY \
--cluster-id 8d6a7c3c-61d5-11e9-a639-34e12d2331a1
+---------------+----------------------------+----------------------------+---------+-----------------------------------------------------------------------+
| job_id | start | end | error | statements |
|---------------+----------------------------+----------------------------+---------+-----------------------------------------------------------------------|
| 0EW7SX3ND87DY | 2024-01-20T08:52:00.008000 | 2024-01-29T08:52:00.014000 | NULL | {"0": {"duration": 0.0021747201681137085, "sql": "DELETE FROM test"}} |
+---------------+----------------------------+----------------------------+---------+-----------------------------------------------------------------------+
clusters scheduled-jobs edit¶
Edit specified scheduled sql job.
Usage: croud clusters scheduled-jobs edit [-h] --job-id JOB_ID --cluster-id
CLUSTER_ID --name NAME --sql SQL
--cron CRON --enabled ENABLED
[--region REGION]
[--output-fmt {table,wide,json,yaml}]
[--sudo]
Required Arguments¶
- --job-id
The id of the job to edit.
- --cluster-id
The cluster id where the job was created.
- --name
The name of the sql job.
- --sql
The sql statement of the sql job.
- --cron
Cron schedule of the sql job.
- --enabled
Enable or disable the sql job.
Optional Arguments¶
- --region, -r
Temporarily use the specified region that command will be run in.
- --output-fmt, --format, -o
Possible choices: table, wide, json, yaml
Change the formatting of the output.
- --sudo
Run the given command as superuser.
Default:
False
Example¶
sh$ croud clusters scheduled-jobs edit \
--job-id 0EW7SX3ND87DY \
--cluster-id 8d6a7c3c-61d5-11e9-a639-34e12d2331a1 \
--name test-job-1 \
--cron "3 2 * * *" \
--sql "SELECT 1;" \
--enabled False
+------------+---------------+-----------+-----------+-----------+
| name | id | sql | cron | enabled |
|------------+---------------+-----------+-----------+-----------|
| test-job-1 | 0EW7SX3ND87DY | SELECT 1; | 3 2 * * * | FALSE |
+------------+---------------+-----------+-----------+-----------+
clusters scheduled-jobs delete¶
Delete specified scheduled sql job.
Usage: croud clusters scheduled-jobs delete [-h] --job-id JOB_ID --cluster-id
CLUSTER_ID [--region REGION]
[--output-fmt {table,wide,json,yaml}]
[--sudo]
Required Arguments¶
- --job-id
The job id of the job to be deleted.
- --cluster-id
The cluster of which the job should be deleted.
Optional Arguments¶
- --region, -r
Temporarily use the specified region that command will be run in.
- --output-fmt, --format, -o
Possible choices: table, wide, json, yaml
Change the formatting of the output.
- --sudo
Run the given command as superuser.
Default:
False
Example¶
sh$ croud clusters scheduled-jobs delete \
--job-id 0EW7SX3ND87DY
--cluster-id 8d6a7c3c-61d5-11e9-a639-34e12d2331a1
==> Success: Scheduled job deleted.