1

I have a autosys job with the below command

cd /homes/epsi95/sanity_check/build-config && ./run.sh postcheck_definition.json

Description: There is a run.sh file inside /homes/epsi95/sanity_check/build-config, I cding into that folder and running the command and passing the command line argument ./run.sh postcheck_definition.json

But the job is failing. But when I run the command from the command line it is working perfectly. How can I fix it?

Epsi95
  • 8,832
  • 1
  • 16
  • 34
  • 1
    Have you tried capturing errors & output from the script? I don't know anything about autosys, but for a cron job I'd add something like `>/tmp/build-config.log 2>&1` to the command. Also, the error's probably some environment dependency, like maybe the `PATH` doesn't have all the entries it needs. – Gordon Davisson May 02 '22 at 08:44
  • Thanks for the suggestion, will try the same. Autosys also has this feature for std_out and std_err, but unfortunately, those log files are empty (cat file.log shows nothing). I search for the 127 error code, it means the command was not found. One of my colleagues saying `&&` is causing the problem but I don't think so, – Epsi95 May 02 '22 at 08:56

1 Answers1

0

I would suggest two ways.

  1. Refer by absolute path (Recommended)

Modify the command to run the script referring the absolute path. Do consider to check and modify the script if using a relative path to absolute path.

command: sh /homes/epsi95/sanity_check/build-config/run.sh postcheck_definition.json
  1. Replace && with ;

In Linux multi-line command can be passed using ; as the keyword.

command: /homes/epsi95/sanity_check/build-config ; ./run.sh postcheck_definition.json
Piyush
  • 818
  • 8
  • 17
  • 1
    The absolute path thing worked, I had this in mind but was at a loss how to get the current folder path in bash since I am using relative paths in the project, this link https://dirask.com/posts/Bash-get-current-script-directory-path-1X9E8D helped me. – Epsi95 May 04 '22 at 14:44