Intel® DevCloud
Help for those needing help starting or connecting to the Intel® DevCloud
1641 Discussions

How To: how-to-print-only-the-job-duration-into-a-file-with-millisecond-precision

WILLIAM_H_Intel4
Employee
861 Views

QUESTION:

While using DevCloud am stuck with the precision of time stamps of job using qstat.
How to change the format of ctime from HH:MM:SS to HH:MM:SS and ms?

How to print ONLY the job duration into a file with millisecond precision?

Job Id: 271467.v-qsvr-1.aidevcloud

  Job_Name = myjob

  Job_Owner = *****@s001-n045

  job_state = R

  queue = batch

  server = v-qsvr-1.aidevcloud

  Checkpoint = u

  ctime = Thu Sep 5 05:09:08 2019

  Error_Path = s001-n045.aidevcloud:/home/*****/****/myjob.e271467

  exec_host = s001-n047/0-1

  Hold_Types = n

  Join_Path = n

  Keep_Files = n

  Mail_Points = n

  mtime = Thu Sep 5 05:09:11 2019

  Output_Path = s001-n045.aidevcloud:/home/*****/****/myjob.o271467

  Priority = 0

  qtime = Thu Sep 5 05:09:08 2019

  Rerunable = True

  Resource_List.nodect = 1

  Resource_List.nodes = 1:ppn=2

  Resource_List.walltime = 06:00:00

  session_id = 6709

  Variable_List = PBS_O_QUEUE=batch,PBS_O_HOME=/home/****,

PBS_O_LOGNAME=****,

PBS_O_PATH=/glob/intel-python/python3/bin/:/glob/development-tools/ve

rsions/intel-parallel-studio/compilers_and_libraries_2019.3.199/linux/

bin/intel64:/glob/development-tools/versions/intel-parallel-studio/com

pilers_and_libraries_2019.3.199/linux/mpi/intel64/libfabric/bin:/glob/

development-tools/versions/intel-parallel-studio/compilers_and_librari

es_2019.3.199/linux/mpi/intel64/bin:/glob/intel-python/python3/bin/:/g

lob/intel-python/python2/bin/:/glob/development-tools/versions/intel-p

arallel-studio/compilers_and_libraries_2019.3.199/linux/bin/intel64:/g

lob/development-tools/versions/intel-parallel-studio/compilers_and_lib

raries_2019.3.199/linux/mpi/intel64/libfabric/bin:/glob/development-to

ols/versions/intel-parallel-studio/compilers_and_libraries_2019.3.199/

linux/mpi/intel64/bin:/glob/intel-python/python3/bin/:/glob/intel-pyth

on/python2/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/hom

e/****/.local/bin:/home/****/bin:/home/****/.local/bin:/home/***/bin:/usr/local/bin:/bin,PBS_O_SHELL=/bin/bash,

PBS_O_LANG=en_US.UTF-8,

PBS_O_SUBMIT_FILTER=/usr/local/sbin/torque_submitfilter,

PBS_O_WORKDIR=/home/*****/****/

PBS_O_HOST=s001-n045.aidevcloud,PBS_O_SERVER=10.9.0.131

  euser = *****

  egroup =****

  queue_type = E

  etime = Thu Sep 5 05:09:08 2019

  submit_args = myjob -F 0

  start_time = Thu Sep 5 05:09:11 2019

  Walltime.Remaining = 21598

  start_count = 1

  fault_tolerant = False

  job_radix = 0

  submit_host = s001-n045.aidevcloud

  job_arguments = 0

 

ANSWER:

 

date +"%s.%3N" returns the current time with nanoseconds rounded to the first 3 digits, which is milliseconds in linux.

You can add the shell commands as in the example below to save the time taken to run your job in milliseconds to text file

 

eg:

 

cd $PBS_O_WORKDIR

STARTTIME=$(date +"%s.%3N")

<YOUR JOB SCRIPT CONTENT>

ENDTIME=$(date +"%s.%3N")

result=$(awk '{print $1-$2}' <<<"${ENDTIME} ${STARTTIME}")

echo $result >> time.txt

 

<YOUR JOB SCRIPT CONTENT> has to be replaced with the content of your job script

 

0 Kudos
0 Replies
Reply