Skip to content

Submit a Batch Job

You're now ready to submit your first job. On NSCC systems, jobs are managed by the PBS Pro scheduler. The scheduler puts your job in a queue and automatically launches it on compute nodes when requested resources become available.

Here are a few simple examples of submitting a batch job.

Submit a Serial Job Using One CPU Core

  1. Create a new file named hello.pbs with the following contents, replacing <project-id> with your project ID:

    #!/bin/bash
    #PBS -q normal
    #PBS -N serial_job
    #PBS -l select=1:ncpus=1:mem=4gb
    #PBS -l walltime=00:10:00
    #PBS -j oe
    #PBS -P <project-id>
    
    cd $PBS_O_WORKDIR
    echo "Hello world!" > hello.txt
    
  2. Submit the job script using qsub:

    qsub hello.pbs
    
  3. Check if job is successful:

    cat hello.txt
    

Submit a Parallel Job Using Multiple CPU Cores

  1. Create a file mpihello.c with following contents:

    #include <mpi.h>
    #include <stdio.h>
    #include <string.h>
    #include <unistd.h>
    
    int main(int argc, char **argv)
    {
      int rank;
      char hostname[256];
    
      MPI_Init(&argc,&argv);
      MPI_Comm_rank(MPI_COMM_WORLD, &rank);
      gethostname(hostname,255);
    
      printf("Hello world!  I am process number: %d on host %s\n", rank, hostname);
    
      MPI_Finalize();
    
      return 0;
    }
    
  2. Create a file parallel.pbs with following contents, replacing <project-id> with your project ID:

    #!/bin/bash
    #PBS -q normal
    #PBS -N parallel_job
    #PBS -l select=1:ncpus=4:mpiprocs=4:ompthreads=1:mem=16gb
    #PBS -l walltime=00:10:00
    #PBS -j oe
    #PBS -P <project-id
    
    cd $PBS_O_WORKDIR
    cc mpihello.c -o mpihello
    mpirun -np 4 ./mpihello > mpihello.txt
    
  3. Submit the job script using qsub:

    qsub parallel.pbs
    
  4. Check if job is successful:

    cat mpihello.txt
    

Check Job Status

Use qstat to check the status of your job:

$ qstat
Job id                 Name             User              Time Use S Queue
---------------------  ---------------- ----------------  -------- - -----
********.pbs101        serial_job       ********                 0 Q qdev

$ qstat -ans

pbs101:
                                                                 Req'd  Req'd   Elap
Job ID               Username Queue    Jobname    SessID NDS TSK Memory Time  S Time
-------------------- -------- -------- ---------- ------ --- --- ------ ----- - -----
********.pbs101      ***      qdev     serial_job    --    1   1    4gb 00:10 E 00:00
   ***/5
   Job run at Thu Sep 11 at 14:54 on (***:ncpus=1:mem=4194304kb)

Run HPC Applications

Please refer to the Application Guides on how to run various HPC/AI applications.