Difference between revisions of "Useful PBS scripts"
Jump to navigation
Jump to search
import>Cen1001 |
import>Cen1001 |
||
Line 1: | Line 1: | ||
If you have put some effort into writing a PBS job script for a particular type of job, please consider adding it here. |
If you have put some effort into writing a PBS job script for a particular type of job, please consider adding it here. |
||
+ | |||
+ | # This is an example PBS job script that can carry out an action to clean up |
||
+ | # after itself when the queueing system terminates the job. You could use it to |
||
+ | # make your code checkpoint or similar. |
||
+ | |||
+ | |||
+ | #PBS -q s4 |
||
+ | #PBS -l walltime=2:00:00 |
||
+ | |||
+ | WD=/scratch/cen1001/work |
||
+ | OUT=$WD/output |
||
+ | |||
+ | # A shell function to clean up after an imaginary job. Replace with whatever's |
||
+ | # appropriate for your job. |
||
+ | cleanup() { |
||
+ | cp $OUT /home/cen1001 && rm $OUT |
||
+ | } |
||
+ | |||
+ | # This function gets called when PBS tells your job to exit. PBS gives a job 60 |
||
+ | # seconds to run its exit handler and then terminates it, so whatever this does |
||
+ | # must happen in less than 60 seconds. |
||
+ | exithandler() { |
||
+ | echo "Job was killed" >> $OUT |
||
+ | cleanup |
||
+ | exit |
||
+ | } |
||
+ | |||
+ | trap exithandler SIGTERM |
||
+ | |||
+ | # The main script starts here |
||
+ | |||
+ | mkdir -p $WD |
||
+ | |||
+ | # do some busy work that generates output |
||
+ | i=0 |
||
+ | while [ $i -lt 100 ] |
||
+ | do |
||
+ | echo $i >> $OUT |
||
+ | sleep 2 |
||
+ | i=$((i+1)) |
||
+ | done |
||
+ | |||
+ | # call the cleanup function |
||
+ | cleanup |
||
+ | |||
+ | # get our PBS stats |
||
+ | qstat -f $PBS_JOBID |
Revision as of 15:20, 12 March 2008
If you have put some effort into writing a PBS job script for a particular type of job, please consider adding it here.
# This is an example PBS job script that can carry out an action to clean up # after itself when the queueing system terminates the job. You could use it to # make your code checkpoint or similar. #PBS -q s4 #PBS -l walltime=2:00:00 WD=/scratch/cen1001/work OUT=$WD/output # A shell function to clean up after an imaginary job. Replace with whatever's # appropriate for your job. cleanup() { cp $OUT /home/cen1001 && rm $OUT } # This function gets called when PBS tells your job to exit. PBS gives a job 60 # seconds to run its exit handler and then terminates it, so whatever this does # must happen in less than 60 seconds. exithandler() { echo "Job was killed" >> $OUT cleanup exit } trap exithandler SIGTERM # The main script starts here mkdir -p $WD # do some busy work that generates output i=0 while [ $i -lt 100 ] do echo $i >> $OUT sleep 2 i=$((i+1)) done # call the cleanup function cleanup # get our PBS stats qstat -f $PBS_JOBID