[torqueusers] Script to extract working directory for running jobs

Cliff Kirby ckirby3 at colsa.com
Wed Feb 8 11:04:15 MST 2006


I wrote the following script to extract the working directory path from all
the running jobs in the PBS queue but it will not work when the
PBS_O_WORKDIR is not on one line by itself.  Is there an easier way to get
just the working directory from all the running jobs from a script?  Or
could someone else share their thoughts on ways I could improve this?

Thanks!

----------------------------------------------------------------
#!/bin/bash

QSTATRUNNING=/tmp/qstatrun.out
QSTATFULL=/tmp/qstatfull.out

#  Check Return Code of qstat command
/opt/torque/bin/qstat -r 1>$QSTATRUNNING

if [ "$?" -ne "0" ]
then
        echo "****************************"
        echo "** QSTAT command failed!! **"
        echo "****************************"
else
        clear
        while IFS="." read jobid ignore
        do
                /opt/torque/bin/qstat -f $jobid 1>$QSTATFULL 2>&1
                if [ "$?" -eq "0" ]
                then
                        if [[ -n $jobid ]]
                        then
                                PBSWORKDIR=`qstat -f $jobid | grep
PBS_O_WORKDIR` 
                                PBSPATH=`echo ${PBSWORKDIR:15}`
                                echo -e "-------- job $jobid in working path
${PBSPATH%,*}"---------"
                        fi
                fi

        done < $QSTATRUNNING   # I/O redirection.
fi

rm $QSTATRUNNING
rm $QSTATFULL
#END OF SCRIPT

------------------------------------------------------------------



More information about the torqueusers mailing list