-2

I am using Runtime.getRuntime().exec() method to run a command and I get exit code 11 when I call Process.waitFor().
When I run the same command on the console it runs as expected.

the command is: hive -hiveconf mapred.map.child.java.opts=-Xmx2048M -hiveconf mapred.job.shuffle.input.buffer.percent=0.30 -hiveconf io.sort.factor=25 -hiveconf io.sort.mb=256 -hiveconf mapred.job.reuse.jvm.num.tasks=500 -hiveconf mapred.job.priority=VERY_LOW -e select site_id,count(session_id) from my_table where day = '20111017' group by site_id;

I am running on Unix machine.

Any idea why? What is exit code 11?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
zohar
  • 2,298
  • 13
  • 45
  • 75
  • 1
    That depends on the program you're starting. If you run it on the command line, type `echo $?` _right after_ it finishes (no other commands in between). – Mat Dec 07 '11 at 14:16
  • I get `command not found: a command`. Seriously, you need to tell us *which* command you are running. Exit codes depend on the program you (try to) invoke! – Has QUIT--Anony-Mousse Dec 07 '11 at 14:21

3 Answers3

1

The exit code is set by the program you call. There is no unique definition, except that 0 is usually no error, and anything else indicates an error. Error codes vary completely from program to program, and some programs do not bother to set an error code.

System.exit(n);

is the Java way to set the exit code to n (an integer value). So, when do ''you'' use System.exit(11);? Then you have your answer...

Has QUIT--Anony-Mousse
  • 76,138
  • 12
  • 138
  • 194
1

Process.waitFor() blocks the thread until exit code from the forked child process is received. In your case this exit code 11 depends on the external command. Please, check the man pages of the external command.

Has QUIT--Anony-Mousse
  • 76,138
  • 12
  • 138
  • 194
0

To fix it I changed the command to be:

hive -hiveconf mapred.map.child.java.opts=-Xmx2048M -hiveconf mapred.job.shuffle.input.buffer.percent=0.30 -hiveconf io.sort.factor=25 -hiveconf io.sort.mb=256 -hiveconf mapred.job.reuse.jvm.num.tasks=500 -hiveconf mapred.job.priority=VERY_LOW -f filename;

As you can see I changed the -e query to -f filename.

zohar
  • 2,298
  • 13
  • 45
  • 75