AutoSys Global Variables — Stale Flags That Skip Batch Runs
Global variables persist until explicitly reset.
- Global variables are name-value pairs stored in the Event Server — any job can read or write them
- Set from a job: sendevent -E SET_GLOBAL -G "COUNT=5432" inside your script
- Read in JIL conditions: variable(TRADING_COUNT) >= 1 — data-driven scheduling
- Read from command line: autostatus -G TRADING_COUNT
- Production killer: globals persist between runs. Monday's COMPLETE flag is still COMPLETE on Tuesday. Reset at workflow start, not end.
- Naming convention: TRADING_RECORD_COUNT, not COUNT. Instance-wide — collisions cause silent failures.
Global variables in AutoSys are like a shared whiteboard in a team's office. Any job can write a value on the board, and any other job can read what's written. Jobs use this to pass information forward in a pipeline — like 'I processed 5,432 records, here's the count for your use.'
AutoSys global variables live in the Event Server. Any job can read them. Any job can write them. They persist until explicitly changed.
That last sentence is where teams get burned.
A flag set to 'COMPLETE' on Monday is still 'COMPLETE' on Tuesday. A counter that reached 5000 yesterday is still 5000 today unless you reset it. This article covers the patterns that work — and the one stale-value trap that breaks workflows silently.
Setting a global variable from a job
Jobs set global variables using the sendevent command with the SET_GLOBAL event. This can be done from within the job's script or from the command line.
The syntax is: sendevent -E SET_GLOBAL -G "VARNAME=value". No spaces around the equals sign.
Critical: SET_GLOBAL events are processed asynchronously. There's a small delay (typically <1 second) between the command and the value being readable by other jobs. If your downstream job starts immediately after setting a variable, it might not see the value yet. Use condition dependencies to enforce order if timing matters.
- Write: sendevent -E SET_GLOBAL -G "NAME=VALUE" — from any job or command line
- Read: autostatus -G NAME — returns current value
- Clear: sendevent -E SET_GLOBAL -G "NAME=" — empty string removes it
- The board persists across days, weeks, restarts. No automatic expiry.
variable(DATA_READY) = 1. The setting job succeeded. The downstream job didn't start.Reading a global variable in a JIL condition
You can reference global variables in JIL conditions using the variable() function. This lets you create data-driven conditions.
Syntax: condition: success(job_a) AND variable(TRADE_COUNT) >= 1000 The comparison operators work: =, !=, <, >, <=, >=. String comparison works too: variable(STATUS) = 'COMPLETE'
Critical: variable() returns an empty string if the global doesn't exist. In numerical comparisons, empty string compares as 0. That can cause false positives — a missing variable might silently pass a >=1 check.
variable() never errors. It returns ''. Build explicit existence checks into your conditions.Global variable naming, lifecycle, and best practices
Global variables persist in the Event Server until explicitly changed or cleared. They do not reset between daily runs — a value set yesterday is still there today unless something overwrites it. This is both powerful and dangerous.
Lifecycle: Created on first SET_GLOBAL. Persists indefinitely. Cleared by SET_GLOBAL with empty value (or by database cleanup). Survives Event Processor restarts, failovers, and system reboots.
Best practices that separate senior engineers from beginners: 1. Always use a naming convention with a workflow prefix (e.g., TRADING_RECORD_COUNT not just COUNT) 2. Reset flags and counters at the start of each workflow run, not the end 3. For per-run state, include the date in the variable name (e.g., TRADING_COUNT_20260319) 4. Document every global variable your workflow uses — undocumented globals become tribal knowledge 5. Audit global variables monthly with autostatus -G % to catch stale or orphaned ones 6. Never assume a global exists. Check before reading.
The Stale Flag That Skipped a Day of Processing
- Global variables persist in the Event Server until explicitly changed.
- Reset at workflow START, not end. A stale flag from yesterday kills today's run.
- Use date-stamped global names for per-run state: TRADING_COUNT_20260319.
- Audit global variables weekly with autostatus -G % to catch stale values.
Key takeaways
Common mistakes to avoid
5 patternsUsing short, generic variable names without workflow prefix
Not resetting globals between runs — resetting at end instead of start
Not checking existence before reading globals in conditions
variable() returns '' which compares as 0. Condition fails (0 >= 100 is false). Workflow stops. No alert — condition just didn't fire.Assuming SET_GLOBAL is instantly readable by downstream jobs
Not documenting globals — undocumented globals become tribal knowledge
Interview Questions on This Topic
What is a global variable in AutoSys?
variable() in JIL conditions
- Instance-wide — no isolation between different workflows or teams
Use cases: Passing record counts, file paths, status flags, or control parameters between jobs in a pipeline.Frequently Asked Questions
JIL syntax, sendevent, autorep, box jobs, file watchers, scheduling, HA, security, cloud workload automation, and 22 interview questions — the definitive AutoSys reference for production engineers.
That's AutoSys. Mark it forged?
3 min read · try the examples if you haven't