If you don't like the names of PBS output and error files, if you don't want your job to go to the default queue, if you have any other special requests, you can specify them by the means of qsub command line switches or PBS directives.
PBS directives are exactly the same as the qsub command line switches, but they are passed to PBS through the script comment lines. For example, in order to change the name of the output file you can use
qsub -o file_nameor you can insert
#PBS -o file_namein the preamble of the script. The effect will be the same.
The three letters,
PBS, that mark
the directive can be
altered too, with the command line switch
-C new_stringBut it's better not to tinker with it, since it may lead to unnecessary confusion down the road.
To rename the error file use the directive:
#PBS -e file_name
The default name of the job, which shows in the second column of
qstat listing, is the name of the submitted file. If you enter
the job interactively, then the name evaluates to STDOUT. Interactive job
is not advisable, because mistakes are easy to make, so
I haven't talked about it, but if you're curious, this is how it
[gustav@bh1 PBS]$ qsub hostname date exit 0 ^D 12672.bh1.avidd.iu.edu [gustav@bh1 PBS]$The output files are then called
[gustav@bh1 PBS]$ ls STDIN.e12672 STDIN.o12672 bc.sh job.sh xterm.sh [gustav@bh1 PBS]$ cat STDIN.o12672 bc68 Mon Sep 8 21:36:52 EST 2003 [gustav@bh1 PBS]$You can change the name of the job with the directive
#PBS -N job_name
The submitted script is interpreted using the user's login shell by default. PBS does not read the
#!/bin/bashline the scripts usually begin with. But this can be altered by using the directive
#PBS -S /bin/bashYou can use also perl or any other scripting language as long as its comment character is the sharp sign,
#(some Schemes allow for the sharp to be used as a comment character too). PBS will scan all the initial comment lines for PBS directives until the first executable line. Any directives embedded in the script after some executable lines will be ignored.
If you don't specify the queue name, the job gets submitted to the default queue. The default queue at most institutions is a short job queue. So normally you have to specify the queue name for longer jobs. This is done with the directive
#PBS -q bg
Let us wrap up the
directives into the following script.
[gustav@bh1 PBS]$ cat simple.sh #PBS -S /bin/bash #PBS -N host #PBS -o host_out #PBS -e host_err #PBS -q bg hostname date exit 0 [gustav@bh1 PBS]$ qsub simple.sh 12673.bh1.avidd.iu.edu [gustav@bh1 PBS]$ ls STDIN.e12672 bc.sh host_out simple.sh STDIN.o12672 host_err job.sh xterm.sh [gustav@bh1 PBS]$ cat host_out bc68 Mon Sep 8 21:58:06 EST 2003 [gustav@bh1 PBS]$
Another two useful PBS directives result in e-mail being sent to you
when the job starts, or terminates or is aborted. The corresponding
-m and it must be followed by
ais the default.
ecan be combined, e.g.,
abe. The corresponding PBS directive looks as follows:
#PBS -m abeNow, who should the mail be sent to? This you can specify by using the
#PBS -M email@example.comYou can also send mail to several users, e.g.,
#PBS -M firstname.lastname@example.org,email@example.comLet us see how this works in combination with our simple job described above.
[gustav@bh1 PBS]$ cat simple.sh #PBS -S /bin/bash #PBS -N host #PBS -o host_out #PBS -e host_err #PBS -q bg #PBS -m abe #PBS -M firstname.lastname@example.org hostname date exit 0 [gustav@bh1 PBS]$ qsub simple.sh 12866.bh1.avidd.iu.edu [gustav@bh1 PBS]$ ls bc.sh host_err host_out job.sh nodes.sh simple.sh xterm.sh [gustav@bh1 PBS]$ cat host_out bc88 Wed Sep 10 16:15:46 EST 2003 [gustav@bh1 PBS]$Mail sent to
email@example.com automatically redirected to my workstation,
woodlands.tqc.iu.edu. Let us have a look then if there are any messages there sent from AVIDD. Here is the updated mail listing from my emacs session:
1 10-Sep firstname.lastname@example.org  \ [Escience] Computer's ability to verify proof is an illusion 2- 10-Sep to: qc@WOODLANDS.tqc.iu.e  \ Quantum dynamics of a single vortex 3- 10-Sep email@example.com  \ PBS JOB 12866.bh1.avidd.iu.edu 4- 10-Sep firstname.lastname@example.org  \ PBS JOB 12866.bh1.avidd.iu.eduTwo messages have arrived from
bh1indeed. The messages may arrive out of order, because this is how e-mail usually works. In this case the second message (number 4 in the emacs listing) corresponds to the job beginning its execution:
Envelope-to: email@example.com Delivery-date: Wed, 10 Sep 2003 16:16:19 -0500 Date: Wed, 10 Sep 2003 16:15:46 -0500 From: adm <firstname.lastname@example.org> To: email@example.com Subject: PBS JOB 12866.bh1.avidd.iu.edu PBS Job Id: 12866.bh1.avidd.iu.edu Job Name: host Begun executionand the first message corresponds to the termination of the job:
Envelope-to: firstname.lastname@example.org Delivery-date: Wed, 10 Sep 2003 16:16:16 -0500 Date: Wed, 10 Sep 2003 16:15:46 -0500 From: adm <email@example.com> To: firstname.lastname@example.org Subject: PBS JOB 12866.bh1.avidd.iu.edu PBS Job Id: 12866.bh1.avidd.iu.edu Job Name: host Execution terminated Exit_status=0 resources_used.cput=00:00:00 resources_used.mem=0kb resources_used.vmem=0kb resources_used.walltime=00:00:00
A good idea is to have the message about your job having been aborted or terminated sent to your cellular phone, if you have this kind of service. This way the message will reach you wherever you may be.