SGE Cluster - script fails after submission - works in terminal

谁说我不能喝 提交于 2019-12-12 03:16:35

问题


I have a script that I am trying to submit to a SGE cluster (on Redhat Linux). The very first part of the script defines the current folder from the full CWD path, as a variable to use downstream:

#!/usr/bin/bash
#
#$ -cwd
#$ -A username
#$ -M user@server
#$ -j y
#$ -m aes
#$ -N test
#$ -o test.log.txt

echo 'This is a test.'
result="${PWD##*/}"
echo $result

In bash, this works as expected:

CWD:

-bash-4.1$ pwd
/home/user/test

Run script:

-bash-4.1$ bash test.sh
This is a test.
test

When I submit the job to the cluster:

-bash-4.1$ qsub -V test.sh

and examine the log file:

This is a test.
Missing }.

Does anyone know why the job submission is saying "Missing } " when it works right from the command-line? I'm not sure what I'm missing here.

Thanks.


回答1:


The posix standard for batch schedulers requires them to ignore the #! line and instead use either a shell configured into the cluster or one selected by the -S option of qsub. The default is usually csh. So adding something like #$ -S /usr/bin/bash into the script will cause it to be interpreted by bash.

Alternatively you could convince the cluster admin to change the queues to unix_behavior from posix_compliant.



来源:https://stackoverflow.com/questions/39578467/sge-cluster-script-fails-after-submission-works-in-terminal

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