AutoSys Global Variables — Stale Flags That Skip Batch Runs
Global variables persist until explicitly reset.
20+ years shipping production infrastructure and CI/CD at scale. Notes here come from systems that actually shipped.
- 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.
How AutoSys Global Variables Become Stale Flags That Skip Batch Runs
AutoSys Global Variables are key-value pairs stored in the AutoSys database that are evaluated at job start time and remain fixed for the duration of that run. They are not dynamic environment variables — once a job begins, the global variable value is frozen, even if the underlying source (e.g., a file, a database query) changes mid-execution. This is the core mechanic: a snapshot, not a live reference.
In practice, global variables are often set by a preceding job (e.g., via sendevent -E SET_GLOBAL) and consumed by downstream jobs. The critical property: the value is resolved only when the job transitions to RUNNING. If a job is queued (ACTIVE) for minutes or hours, the global variable it sees may be stale by the time it actually runs. This is not a bug — it is by design. The variable is a static flag, not a real-time signal.
Use global variables to pass simple state between jobs in a box (e.g., 'FILE_READY=YES') or to parameterize job definitions without editing JIL. They matter in real systems because they are the only built-in mechanism for cross-job coordination without external state stores. But relying on them for time-sensitive decisions (e.g., 'is the upstream table loaded?') is dangerous — the staleness window can cause skipped runs or duplicate processing.
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.
Why Autosys Global Variables Are the Worst Debugging Tool You’re Relying On
You’ve been there: a job fails, you check the logs, and the global variable is empty. Not because it wasn’t set—but because it was set in the wrong scope, or overwritten by a parallel job, or expired before the condition evaluated. Global variables are shared mutable state. Treat them like an unlocked production database. Every job can read and write them. That means a misconfigured nightly data load can silently clobber the flag your critical ETL job depends on. The why is simple: Autosys stores global variables in a flat namespace. No isolation. No versioning. No audit trail. So when you set a variable at 2 AM in one job, and another job reads it at 2:01 AM, you have zero guarantee it’s the same value. The how: always log the variable state at both write and read points. Use a dedicated job to echo the variable into a shared file or monitoring platform before the dependent job runs. That way, when the incident postmortem lands on your desk, you’re not guessing what the value was.
Global Variables as Cross-Domain Handshakes: When They Work and When They Don’t
You can pass global variables between Autosys instances—if your company runs separate domains for dev, staging, and prod. The handshake looks clean on paper: set a variable in Domain A, read it in Domain B via a remote job condition. In practice, this is where global variables become latency grenades. The variable doesn’t replicate instantly. There’s no ACK. No retry. If the remote domain’s event processor is down for 30 seconds, your job condition sees stale data—or nothing. The why is architectural: Autosys domains share variables through a point-to-point daemon protocol. It’s not event-driven. It’s a poll-based sync with a configurable interval (default 60 seconds). That means a job in Domain B might check a variable that hasn’t been updated in Domain A for two minutes. The how: never use a global variable as a real-time handshake between domains. Instead, use a file transfer with a heartbeat check. Write a marker file to a shared NFS mount. Have the remote job check for the file’s existence and age. If the file is older than 5 minutes, kill the job with a clear error. This gives you explicit timeout control, not a silent failure.
Build.Clean: Forcing Autosys to Rebuild Without Manual Override
When a batch pipeline misreads stale global variables, Build.Clean is the failsafe that forces Autosys to discard cached job states and re-execute from scratch. The WHY: Global variables persist across runs and silently block downstream jobs using s(condition). Build.Clean resets the variable to an undefined or zero state before the first job runs, ensuring that conditional logic evaluates fresh input rather than yesterday’s artifact. In practice, you insert a preprocessing job that sets BUILD_CLEAN=1 as an Autosys global, then each downstream job checks that flag early in its JIL condition. Without this, a stale BUILD_CLEAN=0 can cause the entire pipeline to skip rebuilds indefinitely—a silent outage that only surfaces when production data is days old. The HOW: assign the variable in a JIL insert_job block with global_variable parameter, then reference it in downstream conditions as g(BUILD_CLEAN). Never reuse this variable across domains; it must be scoped per pipeline to avoid cross-contamination.
System.AccessToken and System.Debug: Securing and Tracing Global Variable Operations
Autosys doesn’t natively support secret rotation or debug logging for global variables, so you must inject System.AccessToken and System.Debug as engineering conventions. The WHY: global variables store API keys and run IDs in plaintext across job outputs—no encryption, no audit trail. System.AccessToken is a rotating token stored as a global variable but retrieved at runtime from a secure vault (e.g., CyberArk) via a wrapper script. System.Debug toggles verbose logging for variable reads and writes, solving the black-box debugging problem where you can’t tell which job set what value last. The HOW: In the JIL, define a job that fetches the token from vault and writes it to SYSTEM_ACCESS_TOKEN using set_global -n SYSTEM_ACCESS_TOKEN -v ${VAULT_CRED}. Enable debug by having a control job set SYSTEM_DEBUG=1, then condition job scripts to log every $VAR expansion. Without these, a leaked token or an invisible variable change becomes a security incident or a three-day root cause hunt.
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.
autostatus -G % | grep -E 'FLAG|STATUS|DONE'autorep -J WORKFLOW_START_JOB -L 5 | grep SET_GLOBALKey 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.
20+ years shipping production infrastructure and CI/CD at scale. Notes here come from systems that actually shipped.
That's AutoSys. Mark it forged?
6 min read · try the examples if you haven't