Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Can anyone tell me the difference between the following ways of submitting a script:

$ qsub script_name.sh

and

./script_name.sh

What are the differences between the above two ways of submitting a job to a cluster?

Also how come sometimes I need to type:

$ chmod +x script_name.sh 

...before I can type ./script_name.sh to submit a job? How come sometimes I just need to type qsub script_name.sh?

Sorry I'm not very familiar with Unix.

share|improve this question
    
What is qsub? _ –  Hauke Laging Feb 25 at 23:11
    
@HaukeLaging - see my answer. –  slm Feb 25 at 23:16

1 Answer 1

Using a compute cluster?

Since you're asking about qsub I'm going to assume you're using GridEngine or some computer clustering product.

qsub

When you run the command qsub script_name.sh you're telling the cluster's head node that you want to submit a script to run on that server. So that server would need to have access to the same filesystem's that contain the script. For example if your script lives here, /home/myusername/script_name.sh, this file would need to be accessible on both the computer you're running the qsub command on as well as any node in your cluster where you intend script_name.sh to run.

Running a script

When you run the script, ./script_name.sh you're not running anything on the cluster. You're running this script locally on your system. If you've used a command to gain a shell on the cluster, qsh, then you're running this command on whatever node the cluster's scheduler node decided to give you a shell on.

Permissions

Any time you make a script and intend to run it, you have to tell the system your intents, by changing the script's permissions such that they reflect that the file is executable. Otherwise the file is not a script, but just a text file.

You can see a files permissions like so:

some script

$ cat script_name.sh 
#!/bin/bash

echo "hello world"

not executable

$ ls -l script_name.sh 
-rw-rw-r--. 1 saml saml 32 Feb 25 18:11 script_name.sh
$ ./script_name.sh
bash: ./script_name.sh: Permission denied

executable

$ chmod +x script_name.sh 
$ ls -l script_name.sh 
-rwxrwxr-x. 1 saml saml 32 Feb 25 18:11 script_name.sh
$ ./script_name.sh
hello world
share|improve this answer
    
Hi slm, thanks for your reply. But I am little bit confused about what it means when you say " If you've used a command to gain a shell on the cluster, qsh, then you're running this command on whatever node the cluster's scheduler node decided to give you a shell on." –  john_w Feb 26 at 19:11
    
@john_w - what clustering technology are you using here? GridEngine or something else? –  slm Feb 26 at 19:23
    
Hi, sorry I am not sure what clustering technology mean, I am extremely newbie. I know that I have a bashrc file. How do I find out the GridEngine? do I type some command on the command line to find out? –  john_w Feb 26 at 19:32
    
Also I have a script that calls for another script. The script start_prephasing.sh calls prephasing.sh in using a loop in the start_prephasing.sh. I was using qsub to submit star_prephasing.sh, but I receives the error of "/var/spool/n1ge/cn-r10-7/job_scripts/4304571: line 9: qsub: command not found". But when I type chmod +x start_prephasing.sh and then the 22 jobs of the prephasing.sh will run successfully. I am not sure why, I think I still don't fully understand the difference between qsub start_prephasing.sh and ./start_prephasing.sh yet. –  john_w Feb 26 at 19:36
    
This is what I have in the start_prephasing.sh script: #$ -S /bin/bash #$ -cwd export HOME=/adp/home/hswong/CACTI/imputation/prephasing let a=1 b=22 while [ $a -le $b ] do qsub -q long.q -o ~/queue -e ~/queue prephasing.sh $a #qsub -pe parallel 4 -q parallel_long.q -o ~/queue -e ~/queue prephasing.sh $a let a=$a+1 done –  john_w Feb 26 at 19:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.