Job System on Server

PBS

Useful commands

  • qsub:submit jobs
  • qstat:check states of jobs
  • qdel:kill jobs

Example of PBS job file:

#!/bin/bash

#PBS -N zmodel; Name of job

#PBS -q normal; queue that used for computation

#PBS -o zmodel.log; log file for the job

#PBS -e zmodel.err; err file for the job

#PBS -m bea; optional to send you job states by email

#PBS -l walltime=16:00:00; maximum running time for the job

#PBS -l nodes=1:ppn=1; number of nodes and CPU used for the job

cd /Users/jiang/Documents/Projects/HuaBai/code/server; #goto the folder for the job

R CMD BATCH --vanilla '--args 3 38.000000 200' test.R zmodel.Rout # run the R procedure by command line

you can submit the job by command Rscript sub.R.

The code for sub.R is shown in the following:

# The content of file sub.R

      task_name='zmodel' # define your job name
      qsub_file=paste0(task_name,'.txt') # define the name of the job file according to job name
      jobname=task_name  
      logname=paste(task_name,'.log',sep='') 
      errfile=paste(task_name,'.err',sep='') 
      
      sink(qsub_file) # link to the job file 
      
      cat('#!/bin/bash\n')
      cat('\n')
      cat(sprintf("#PBS -N %s\n",jobname))
      cat('\n')
      cat('#PBS -q normal\n')
      cat('\n')
      cat(sprintf("#PBS -o %s\n",logname))
      cat('\n')
      cat(sprintf("#PBS -e %s\n",errfile))
      cat('\n')
      cat('#PBS -m bea')
      cat('\n')
      cat('#PBS -l walltime=16:00:00')
      cat('\n')
      cat('#PBS -l nodes=1:ppn=1')
      cat('\n')
      
      dir<-getwd()
      cat(paste('cd',dir,'\n'))
      out=task_name
      
      cat(sprintf("R CMD BATCH --vanilla '--args %d %f %d' test.R %s.Rout   \n",Mod,Rs[j],state,out)) 
      # setting parameters for calling the R procedure
      
      sink() # unlink to the job file
      
      com=paste('qsub',qsub_file) # generating system command for submitting jobs
      
      system(com) # submit the job 

Homework: Using R to kill your jobs.

LSF

Useful commands

  • bqueues:check job queues
  • bhosts:check computation nodes
  • lsload:check loadings
  • bsub:submit jobs
  • bjobs:check states of jobs
  • bkill:kill jobs
  • bpeek:check output from jobs
  • bhist:historical information of jobs

Example of LSF job file:

#BSUB -J zmodel; Name of job

#BSUB -q normal; queue that used for computation

#BSUB -o zmodel.log; log file for the job

#BSUB -e zmodel.err; err file for the job

#BSUB -n 1; number of nodes used for the job

#BSUB -W 10:00; maximum running time for the job (hh:mm)

cd /Users/jiang/Documents/Projects/HuaBai/code/server; #goto the folder for the job

R CMD BATCH --vanilla '--args 3 38.000000 200' test.R zmodel.Rout # run the R procedure by command line

Homework: using R to generate your lsf job file