Interactive jobs are great for development and testing but if you’re running something that takes a long time then they aren’t ideal. Typically it is better to write a script to automate everything that you would have had to do by hand. A minimal jobscript for the PBS/Torque batch system used on Saguaro might look something like this:
#!/bin/bash
#PBS -l nodes=1
#PBS -j oe
#PBS -o My_Log_file.txt
#PBS -l walltime=00:01:00
cd $PBS_O_WORKDIR
saguaro2:~/ > qsub my_job_script.pbs4213885.moab.local
Here is how to automate the submission of multiple jobs. Say you want to run a parameter sweep with one matlab job per point. One approach may be to pass the parameter value to your matlab orogram (call it “myprogram.m”) as an argument. Now, all we need to do is automate the writing of the submission script. Let’s create one file called “scripttop.”
#!/bin/bash#PBS -l nodes=1:ppn=1#PBS -N matlab#PBS -l walltime=1:00:00#PBS -j oecd $PBS_O_WORKDIRmodule load matlab/R2012b
for f in 1 2 3 4 5 ; domkdir $fcd $fcat ../scripttop > runjobecho “matlab -nodesktop -nodisplay -nojvm -r \”myprogram($f)\”” >> runjobqsub runjobcd ..done
saguaro2:~/ > chmod u+x job_launchersaguaro2:~/ > ./job_launcher