Prologues and Epilogues
Job prologues and epilogues allow you to execute shell scripts before your job starts, or after it completes.
In torque, you can specify a prologue or epilogue with the resource (-l) switch, i.e…
qsub -l nodes=1:ppn=20,epilogue=/path/to/epilogue.sh
Then, what the script does is entirely up to you. You may want to perform pre or post file processing, copy operations, or even job modifications for preempted jobs…
mjobctl -m reqreservation=hpcadmin_lab $1
The epilogue script will fire on job completion and also in the event of preemption. In the above example, this epilogue script would change the job reservation if the job was somehow requeued. As seen here, torque passes certain arguments to your script that you can use. In bash, you would reference these positionally just like normal shell script arguments, i.e. $1, $2, etc.
More information on the prologue and epilogue features, including the available arguments can be found at …