Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the PBS qsub to run a script on a cluster that must output a report file named with the batch job submit time.

The batch job submit time is the time it joins the PBS batch job que.

I checked all PBS default variables but I didn't find anything related to the job submit time.

I would like to know how can I get this time without creating a new input variable.

Thanks.

share|improve this question
up vote 1 down vote accepted

I figured out this by myself.

Add the following function into your PBS batch job script to get the job submit time.

getsubmitdate(){
   local datestring=`qstat -f $PBS_JOBID | grep -F qtime | awk '{for(i=3;i<8;i++) printf $i" "}'`;
   local result=`date -d "$datestring" +%Y%m%d` ;
   local outputvar=$1 ;
   if [[ "$outputvar" ]] ; then
       eval $outputvar="'$result'"
   else
       echo "$result"
   fi
}

getsubmitdate SUBMITDATE
echo $SUBMITDATE
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.