PBS script -o file to multiple locations

扶醉桌前 提交于 2019-12-05 16:46:49

I'm very surprised that your command line example worked. Did your job actually run? My guess is that running

echo "hello" | qsub -o `tee $HOME/out1.o $HOME/out2.o $HOME/out3.o`

short circuits the job running and actually just grabs "hello" and passes it to tee. My guess is that someone who knows bash a bit better could explain what is actually happening here.

The only way I can think of to make what you're requesting work would be to have your script write things to tee. In order for this to work, you'd need to have the locations be on a network filesystem that is accessible from any possible compute node.

I studied a qsub man page and I don't think there is a method to specify more than one output file (each) for standard output and standard error. Taking cues from this page, here is a way I achieved something similar to your goals. Your PBS environment may be a little different. Also, I am not a bash expert, so there may be more concise methods of achieving the same thing.

Assuming you're using the default -o settings, at the end of your regular job script put the commands:

# change to the directory from which this job was submitted
cd $PBS_O_WORKDIR

# the standard output by default will be in file JOBNAME.oJOBID
# on my system, PBS_JOBID has ".machinename" at the end, which needs to be removed

filename=${PBS_JOBNAME}.o${PBS_JOBID%%.*}

echo "${PBS_O_WORKDIR}/copy.pbs $filename" | qsub

This will launch qsub using the stdin arguments telling it to run "copy.pbs" with the filename argument to be copied. The copy.pbs file I used is:

#!/bin/bash

# change to the directory from which this job was submitted
cd $PBS_O_WORKDIR

newfile=${HOME}/jobOuts/$1

cp $1 $newfile

This worked for me to copy the first PBS standard output to another directory. A side effect is that running copy.pbs with qsub creates another two output files, STDIN.e* and STDIN.o*. I figured using qsub again was a good idea to make sure the first job had finished. To be more safe, you could use the "depends on option" with qsub, such as "-W depend=afterok:$PBS_JOBID copy.pbs $filename" | qsub. But I did not test this method and like I said, I'm not an expert in any of this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!