All Products
Search
Document Center

Microservices Engine:System variables of scripts

Last Updated:Mar 11, 2026

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

VariableDescriptionExample
#{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.

VariableDescriptionExample
#{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

VariableDescriptionExample
#{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:

ValueMeaning
1Periodic scheduling
2Data refresh
3API scheduling
4Manual rerun
5System retry
6Manual 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