SGE provides the qsub command for submitting batch jobs: Use this command to submit a batch job:
where [~tloizou:[job_script]] is the name of a UNIX format text file containing job script commands. This file should contain both shell commands and special statements that include qsub options and resource specifications. Some of the most common options are described in Table 2. Details on using these options and examples of job scripts follow.
|-q||[[queue_name]]||Submits to queue designated by [[queue_name]].|
|-pe||[[TpN]]way [[NoN x 16]]||Executes the job using the specified number of tasks (cores to use) per node ("wayness") and the number of nodes times 16 (total number of cores). (See example script below.)|
|-N||[[job_name]]||Names the job [job_name].|
|-S||[[shell_absolute_path]]||Use the command shell specified for the batch session.(See example script below.)|
|-M||[[email_address]]||Specify the email address to use for notifications.|
|-m||Specify when user notifications are to be sent.|
|-V||Use current environment setting in batch job.|
|-cwd||Use current directory as the job's working directory.|
|-j||y||Join stderr output with the file specified by the -o option. (Don't also use the -e option.)|
|-o||[[output_file]]||Direct job output to [output_file].|
|-e||[[error_file]]||Direct job error to [error_file]. (Don't also use the -j option.)|
|-A||[[project_account_name]]||Charges run to [project_account_name]. Used only for multi-project logins. Account names and reports are displayed at login.|
|-l||[[resource]]=[[value]]||Specify resource limits. (See qsub man page.)|
Options can be passed to qsub on the command line or specified in the job script file. The latter approach is preferable. It is easier to store commonly used qsub commands in a script file that will be reused several times rather than retyping the qsub commands at every batch request. In addition, it is easier to maintain a consistent batch environment across runs if the same options are stored in a reusable job script.
Batch scripts contain two types of statements: special comments and shell commands. Special comment lines begin with #$ and are followed with qsub options. The SGE shell_start_mode has been set to unix_behavior, which means the UNIX shell commands are interpreted by the shell specified on the first line after #! sentinel; otherwise the Bourne shell (/bin/sh) is used. The file job below requests an MPI job with 8 cores and 1.5 hours of run time:
If you don't want stderr and stdout directed to the same file, replace the -j option line, with a -e option to name a separate output file for stderr (but don't use both). By default stderr and stdout are sent to two separate files.
If you don't want stderr and stdout directed to the same file, replace the -j option line, with a -e option to name a separate output file for stderr (but don't use both). By default, stderr and stdout are sent to out.o and err.o, respectively.
Example job scripts are available online in /share/doc/sge/XYZ. They include details for launching large jobs, running multiple executables with different MPI stacks, executing hybrid applications, and other operations.