Job Command Fails In AutoSys But Works From Command Line
search cancel

Job Command Fails In AutoSys But Works From Command Line

book

Article ID: 145795

calendar_today

Updated On:

Products

CA Workload Automation AE - Scheduler (AutoSys) Autosys Workload Automation

Issue/Introduction

When we run a command job to run a shell script the job fails with error.

We run the same script manually, the script runs successfully.

Environment

Release : 11.3.6

Component : CA Workload Automation AE (AutoSys)

Resolution

When you can run the shell script by the "same user" and on the "same Agent",

then the encountered problem is related to the "job environment" being different from the "interactive environment".


The recommended solution is to proceed by the following steps to address the encountered issue:

1. Login as the "job owner" on the same "Agent machine" where the shell script needs to run

2. Run the shell script manually to make sure it works fine

3. Run a test job with exactly the same job definition as the job you need to run with a few changes as below:

The command will need to be modified to "set" if the Agent is on Windows, "env" if the Agent is on Linux/Unix.

The job name will be modified to a different name

The output of the command ("set" or "env") will be sent to the std_out_file of the job


Example for Windows:

insert_job: environment_test
......
command: set < =====
....
std_out_file: C:\Windows\Temp\environment_test.res
......


Example for Linux/Unix:

insert_job: environment_test
......
command: env < =====
....
std_out_file: /tmp/autosys/environment_test.res
......


4. Run the job from the GUI (WCC or iXp) or by using the following command:

sendevent -E STARTJOB -J environment_test


5. The C:\Windows\Temp\environment_test.res file will contain the result of "set" from the job for Windows.

     The /tmp/autosys/environment_test.res file will contain the result of "env" from the job for Linux/Unix.


6. Run the command "set > interactive_set.res" from the interactive login of the same user on Windows

    Run the command "env > interactive_env.res" from the interactive login of same user on Linux/Unix


7. Compare the "environment_test.res" file and "interactive_set.res" file on Windows

   Compare the "environment_test.res" file and "interactive_env.res" file on Linux/Unix


8. Build a file called "job_profile" with all the environment variables needed for the shell script which are missing in "environment_test.txt"


9. Add a "profile" attribute to your job definition with the required environment variables built in step 8.

update_job: jobname
.....
profile: C:\....\ job_profile < =====  For Windows


update_job: jobname
.....
profile: /dir1/dir2/job_profile < ===== For Linux/Unix