Command Job Fails With Exit Code 2
search cancel

Command Job Fails With Exit Code 2


Article ID: 37196


Updated On:


CA Workload Automation AE - Business Agents (AutoSys) CA Workload Automation AE - Scheduler (AutoSys) Workload Automation Agent


A command job that runs a shell script on UNIX fails with exit code 2. The error that is written to the std_err_file indicates that the script cannot be found...

cybspawn: Wed Jan 27 10:27:12 2016:101.4_1/WAAE_WF0.1/MAIN: Could not exec /tmp/ error 2 (No such file or directory)

However, the script is verified to exist in the specified path, has proper execute permissions for the job owner



Release: ATSYHA99000-11.3.6-Workload Automation AE-High Availability Option


The error was actually coming from the first line in the job script where the shell was being sourced. The first line read '#!/usr/bin/ksh'. However, this was an invalid line for setting the shell interpreter which are typically in /bin and not /usr/bin. 

The error that was written to the error log was impacted by the oscomponent.cmdprefix.force setting for the agent. When this parameter is either not set, or set to "false", the job's command is run directly by the agent using the 'exec' command. Because of that, the error wasn't as descriptive as it would have been if executed without the 'exec' command. When the parameter is set to "true", the job's command is executed by a wrapper script that is build by the agent and the logged error becomes much more descriptive of the actual problem. Here is an example of the same job failure with the oscomponent.cmdprefix.force set to "true"...

/opt/CA/WorkloadAutomationAE/SystemAgent/WA_AGENT/spool/PL1_SCH/MAIN/WAAE_WF0.1/ /tmp/ /usr/bin/ksh: bad interpreter: No such file or directory


The shell source line in the script was corrected to resolve the error. 

For WAAE, it is recommended to set oscomponent.cmdprefix.force=true in the agentparm.txt file to maintain compatibility with jobs run under previous WAAE releases. This is set automatically when the agent is installed by the WAAE media. However, if the agent is installed using the generic agent media, you must select "legacy compatibility" during the install for it to be set automatically.