2014-01-05 23 views
1

我在我的home文件夹下安装了R,并且我想在将作业提交给群集时调用新的R。群集节点都安装了CentOS。别名在qsub后不起作用

下面是我在.bash_profile文件和.bashrc中所做的配置:

if [ `lsb_release -i|cut -c17-20` == 'Cent' ] ; then 
    alias R='/home/XXX/R-3.0.2/bin/R' 
    alias Rscript='/home/XXX/R-3.0.2/bin/Rscript' 
fi 

我加入的.bash_profile如下:

if [ -f ~/.bashrc ]; then 
    source ~/.bashrc 
fi 

我还添加了这所提交的脚本。

source $HOME/.bash_profile 

我试着用qsub -I,它工作的很完美。

但是,我提交作业后,which R仍然显示原始路径!

如何正确设置环境?

回答

1

别名不影响which命令,例如:

$ which R 
/usr/bin/R 
$ alias R=/bin/date 
$ R 
Sun Jan 5 13:40:54 CET 2014  # as you see the alias works 
$ which R       # `which R` still returns the original path 
/usr/bin/R 

而不是使用别名,我觉得要前置/home/XXX/R-3.0.2/binPATH

PATH="/home/XXX/R-3.0.2/bin:$PATH" 

在此之后,如果RRscript存在于/home/XXX/R-3.0.2/bin中,则:

  • which R应该返回/home/XXX/R-3.0.2/bin/R
  • which Rscript应该返回/home/XXX/R-3.0.2/bin/Rscript

,因为他们将在/home/XXX/R-3.0.2/bin首先发现,在$PATH其余任何其他目录之前。

+0

谢谢@janos。我创建了一个.env文件,并在其中添加了PATH =“/ home/XXX/R-3.0.2/bin:$ PATH”,然后在if命令中检测到CentOs时源文件。 – shao