![LSF-糟糕的资源需求语法错误](https://linux22.com/image/584360/LSF-%E7%B3%9F%E7%B3%95%E7%9A%84%E8%B5%84%E6%BA%90%E9%9C%80%E6%B1%82%E8%AF%AD%E6%B3%95%E9%94%99%E8%AF%AF.png)
我正在尝试使用 LSF 中提供的内存资源分配命令。该命令的正常格式为:
bsub -R "rusage [mem=1000]" 睡眠 100 秒
当我直接从终端启动此命令时,它可以工作。当我从脚本中运行此命令时,它会失败。
这是我的脚本:
#! /bin/csh -f
set cktsim_memory = $1
set tmp = "|rusage [mem = $cktsim_memory]|" #method2
set tmp = `echo $tmp | sed 's/ =/=/g'` #method2
set tmp = `echo $tmp | sed 's/|/"/g' `
set bsub_option = ""
set bsub_option = ( "$bsub_option" "-R" "$tmp") #method2
set cmd = "bsub $bsub_option sleep 100s"
echo $cmd
$cmd
其运行输出为:
>./cktsim_memory_test 100
bsub_option -R "rusage [mem= 100]"
Bad resource requirement syntax. Job not submitted.
>bsub -R "rusage [mem= 100]" sleep 100s
Job <99775> is submitted to default queue <medium>.
正如您在上面的终端输出中看到的 - 当从脚本启动 bsub 命令时,它会失败,而当从终端运行相同的命令时,它会正常......
请帮我调试这个问题。
答案1
将您的命令放在引号中并进行一些细微的修改。
bsub -q medium -R 'rusage[mem=1000 ]' 'cd ; ./run_command'
-or-
bsub -q medium -R 'rusage[mem=1000 ]' './FULL_PATH/run_command'
注意: - 确保可以从执行主机访问“run_command”
答案2
这是工作代码:
#! /bin/csh -f
set cktsim_memory = $1
set tmp = "'rusage [mem = $cktsim_memory]'" #method2
set tmp = `echo $tmp | sed 's/ =/=/g'` #method2
set bsub_option = ""
set bsub_option = ( "$bsub_option" "-R" "$tmp") #method2
set cmd = "bsub $bsub_option sleep 100s"
echo $cmd > lsfcmd ; source lsfcmd