Skip to content
Last updated

Job Commands

Manage and execute Treasure Data jobs (queries).

Commands

tdx jobs                              # List jobs
tdx job list                          # Same as jobs
tdx job schedule list                 # List scheduled queries

List Jobs

# List jobs (default: 40 jobs)
tdx jobs

# List more jobs
tdx jobs --limit 100

# Filter by status
tdx jobs --status running
tdx jobs --status success
tdx jobs --status error
tdx jobs --status queued

# Combine filters
tdx jobs --status running --limit 50

# Output as JSON
tdx jobs --json

Show Job Details

# Show job details
tdx job show <job-id>

# Show as JSON
tdx job show <job-id> --json

Submit Jobs

# Submit Trino query (default)
tdx job submit "SELECT * FROM mydb.table LIMIT 10"

# Submit with specific database
tdx job submit "SELECT * FROM table" --database mydb

# Submit Hive query from file
tdx job submit --job-type hive -f query.sql --database mydb

# Submit without specifying database
tdx job submit "SELECT 1"

# Submit with result export destination (URL format)
tdx job submit "SELECT * FROM table" --database mydb --result "s3://bucket/path"

# Submit with result export destination (JSON format)
tdx job submit "SELECT * FROM table" --database mydb \
  --result '{"type":"s3_v2","td_authentication_id":12345,"bucket":"my-bucket","path":"/output/result.csv","format":"csv"}'

Get Job Results

# Get job results (table format)
tdx job result <job-id>

# Get results as JSON
tdx job result <job-id> --json

# Save results to file
tdx job result <job-id> --output results.json

# Get results as TSV
tdx job result <job-id> --tsv

Kill a Job

# Kill a job (with confirmation)
tdx job kill <job-id>

# Skip confirmation prompt
tdx job kill <job-id> --yes

Job Command Options

OptionDescriptionDefault
--job-type <type>Job type (trino or hive)trino
-f, --file <path>Read query from file-
--database <name>Database nameinformation_schema
--result <target>Result export destination (URL or JSON)-
--status <status>Filter by status (for jobs list)-
--limit <number>Maximum jobs to list40

Status Values

StatusDescription
queuedJob is waiting to run
runningJob is currently executing
successJob completed successfully
errorJob failed with an error

Scheduled Queries

Manage scheduled queries (cron-based job execution).

List Schedules

# List all scheduled queries
tdx job schedule list

# Filter by wildcard pattern
tdx job schedule list "daily*"        # Starts with "daily"
tdx job schedule list "*_sync"        # Ends with "_sync"
tdx job schedule list "*hourly*"      # Contains "hourly"
tdx job schedule list "report_?"      # Single character wildcard

# Limit results
tdx job schedule list --limit 100

# Output as JSON
tdx job schedule list --json

The default output shows a compact list with status icon, last run time, next run time, cron expression, and schedule name (with link to TD Console).

Pattern Syntax

PatternMatches
*Any characters (zero or more)
?Any single character

Pattern matching is case-insensitive.

Show Schedule Details

# Show schedule details
tdx job schedule show <name>

# Show as JSON
tdx job schedule show <name> --json

Create a Schedule

# Create a scheduled query (minimal)
tdx job schedule create my-schedule \
  -d mydb \
  --file query.sql

# Create with cron expression
tdx job schedule create my-schedule \
  -d mydb \
  --file query.sql \
  --cron "0 0 * * *" \
  --timezone "America/Los_Angeles"

# Create with all options
tdx job schedule create my-schedule \
  -d mydb \
  --file query.sql \
  --type trino \
  --cron "0 0 * * *" \
  --timezone "America/Los_Angeles" \
  --delay 60 \
  --priority 1 \
  --retry-limit 3 \
  --engine-version stable \
  --result "td://mydb/result_table"

Update a Schedule

# Update cron expression
tdx job schedule update my-schedule --cron "0 12 * * *"

# Update query from file
tdx job schedule update my-schedule --file new-query.sql

# Update multiple options
tdx job schedule update my-schedule \
  -d newdb \
  --priority 2 \
  --retry-limit 5

Delete a Schedule

# Delete a schedule (with confirmation)
tdx job schedule delete my-schedule

# Skip confirmation prompt
tdx job schedule delete my-schedule --yes

Run a Schedule Immediately

# Run immediately with current time
tdx job schedule run my-schedule

# Run with specific scheduled time
tdx job schedule run my-schedule --time "2025-01-15T00:00:00Z"

# Run multiple times (1-10)
tdx job schedule run my-schedule --num 3

Show Schedule History

# Show execution history (default: last 20)
tdx job schedule history my-schedule

# Show with pagination
tdx job schedule history my-schedule --from 0 --to 50

# Output as JSON
tdx job schedule history my-schedule --json

Schedule Command Options

Create Options

OptionDescriptionDefault
-d, --database <name>Database name (required, global option)-
-f, --file <path>Read query from file (required)-
--type <type>Query type (trino or hive)trino
--cron <expression>Cron expression for scheduling-
--timezone <tz>Timezone for cronUTC
--delay <seconds>Delay in seconds before execution-
--priority <-2~2>Job priority (-2 to 2)-
--retry-limit <0~32>Retry limit (0 to 32)-
--engine-version <version>Query engine version-
--result <url>Result output destination URL-

Update Options

All create options are available (all are optional for update).

Run Options

OptionDescriptionDefault
--time <iso8601>Scheduled time (ISO 8601 format)now
--num <1-10>Number of executions1

List Options

OptionDescriptionDefault
[pattern]Wildcard pattern to filter names (* any chars, ? single char)-
--limit <number>Maximum schedules to return40

History Options

OptionDescriptionDefault
--from <n>Starting offset0
--to <n>Ending offset20