Redirect output of my java program under qsub

2019-07-28 04:15发布

问题:

I am currently running multiple Java executable program using qsub.

I wrote two scripts: 1) qsub.sh, 2) run.sh

qsub.sh

#! /bin/bash
echo cd `pwd` \; "$@" | qsub

run.sh

#! /bin/bash
for param in 1 2 3
do
./qsub.sh java -jar myProgram.jar -param ${param}
done

Given the two scripts above, I submit jobs by

sh run.sh

I want to redirect the messages generated by myProgram.jar -param ${param}

So in run.sh, I replaced the 4th line with the following

./qsub.sh java -jar myProgram.jar -param ${param} > output-${param}.txt

but the messages stored in output.txt is "Your job 730 ("STDIN") has been submitted", which is not what I intended.

I know that qsub has an option -o for specifying the location of output, but I cannot figure out how to use this option for my case.

Can anyone help me?

Thanks in advance.

回答1:

The issue is that qsub doesn't return the output of your job, it returns the output of the qsub command itself, which is simply informing your resource manager / scheduler that you want that job to run.

You want to use the qsub -o option, but you need to remember that the output won't appear there until the job has run to completion. For Torque, you'd use qstat to check the status of your job, and all other resource managers / schedulers have similar commands.