SchedulerX provides built-in system variables that you can reference at runtime in script tasks. These variables give you access to job parameters, sharding context, and execution metadata without hardcoding values.
All variables use the #{schedulerx.<variable>} syntax.
Note
The agent version must be 1.12.5 or later.
Scheduling context
| Variable | Description | Example |
|---|---|---|
#{schedulerx.jobParameters} | The job parameter. | test |
#{schedulerx.triggerType} | How the job was triggered. See Trigger types. | 1 |
#{schedulerx.scheduleTime} | The scheduling timestamp, accurate to milliseconds. | 1743150114875 |
#{schedulerx.dataTime} | The data timestamp, accurate to milliseconds. | 1743150114875 |
Sharding variables
These variables provide shard-level context for broadcast jobs and sharding jobs.
| Variable | Description | Example |
|---|---|---|
#{schedulerx.shardingId} | The shard ID. Supported by broadcast jobs and sharding jobs. | 0 |
#{schedulerx.shardingParameters} | The shard parameter. Supported by sharding jobs only. | hangzhou |
#{schedulerx.shardingNum} | The total number of shards. Supported by broadcast jobs and sharding jobs. | 2 |
Execution state
| Variable | Description | Example |
|---|---|---|
#{schedulerx.attempt} | The number of times the job has been retried. 0 on the first run. | 0 |
Trigger types
The #{schedulerx.triggerType} variable returns one of the following integer values:
| Value | Meaning |
|---|---|
| 1 | Periodic scheduling |
| 2 | Data refresh |
| 3 | API scheduling |
| 4 | Manual rerun |
| 5 | System retry |
| 6 | Manual run |
Usage example
The following Shell script shows how to reference system variables:
#!/bin/bash
# Access scheduling context
echo "Job parameter: #{schedulerx.jobParameters}"
echo "Trigger type: #{schedulerx.triggerType}"
echo "Schedule time: #{schedulerx.scheduleTime}"
echo "Data time: #{schedulerx.dataTime}"
# Sharding context (broadcast and sharding jobs only)
echo "Shard ID: #{schedulerx.shardingId}"
echo "Shard parameter: #{schedulerx.shardingParameters}"
echo "Total shards: #{schedulerx.shardingNum}"
# Execution state
echo "Attempt: #{schedulerx.attempt}"After variable substitution, the output resembles:
Job parameter: test
Trigger type: 1
Schedule time: 1743150114875
Data time: 1743150114875
Shard ID: 0
Shard parameter: hangzhou
Total shards: 2
Attempt: 0