1

I am trying to use the memory resource allocation command available in LSF. A normal format of the command is :

bsub -R "rusage [mem=1000]" sleep 100s

When I launch this command directly from terminal,it works. When i lsunch this command from a script, it fails.

Here is my script:

#! /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

Its run output is:

>./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>.

As you can see in the terminal output above- when the bsub command launched from script, it fails, when the same command run from terminal it is ok...

Please help me debug the issue.

Ani
  • 111
  • 4

2 Answers2

0

Put your command in quotes with some slight modifications.

     bsub -q medium -R 'rusage[mem=1000 ]' 'cd ; ./run_command' 
     -or-
     bsub -q medium -R 'rusage[mem=1000 ]' './FULL_PATH/run_command'

Note: - Make sure the "run_command" is accessible from your execution host

Chakri
  • 1,070
  • 6
  • 8
  • I don't think that is the issue, We can replace the run_command script with a simple sleep command and still the problem remains. – Ani May 17 '12 at 07:49
  • Please refer the question again, I have updated it. – Ani May 17 '12 at 07:49
  • Ahaa ! I had a similar experience with quotes..here is your issue. Remove your double quotes with single. set cmd = "bsub $bsub_option sleep 100s" ==> set cmd = 'bsub $bsub_option sleep 100s'. I tested and it worked. Used "csh -x " to debug. – Chakri May 17 '12 at 13:48
  • Sorry its not REMOVE but REPLACE the double qoutes with single qoutes in your set cmd line. – Chakri May 17 '12 at 19:44
  • There seem to be a missing issue here : let a = 123 , echo "$a" gives 123, while echo '$a' gives $a , using single quotes will not interpret the variables. – Ani May 18 '12 at 03:15
  • Your point did help, please check the answer I have posted. – Ani May 18 '12 at 03:54
0

This is the working code:

#! /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
Ani
  • 111
  • 4
  • Replacing double quotes with single at the last set line, as shown below worked. Here is working code. code. #! /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 – Chakri May 18 '12 at 16:32