[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Condor-users] format for timestamps with condor_q -format?



On Tue, 7 Mar 2006, Steven Timm wrote:

Is there any way to take the various time fields
that appear in condor_q -long
QDate, JobStartDate, etc
and use condor_q -format to put them in a human-readable format
instead of number of seconds since the epoch?

Steve Timm

Here is a program written in lex that I have used to convert the dates
and times into readable form.  I haven't checked whether the regexp
matches all and only date/time values printed by condor_q -l.

%{

/*
 * $Id: condor_q-filter.l,v 1.1 2004/08/05 19:07:01 yindw Exp $
 *
 * This program scans the output of "condor_q -l" and converts times
 * expressed as seconds since 1970 January 1 into readable form.
 *
 * To use this program, run
 *
 *   condor_q -l -name <schedd> <cluster.id> | condor_q-filter
 *
 * where <schedd> is the name of the Condor submit queue and
 * <cluster.id> is the job number.
 *
 * To compile this program, run
 *
 *   flex condor_q-filter.l
 *   gcc -o condor_q-filter lex.yy.c -ll
 *
 */

#include <stdio.h>
#include <string.h>
#include <time.h>

char label[64], readable_time[26];
time_t thetime;

%}

%%

^[A-Z][a-zA-Z]+[ ]=[ ][1-9][0-9]{9}$ {
  sscanf(yytext,"%s = %ld",label,&thetime);
  strncpy(readable_time,ctime(&thetime),24);
  printf("%s = %s  (%d)",label,readable_time,thetime);
}

.       ECHO;

%%
int main () {
  yylex();
}



--
Mr. De-Wei Yin, MASc, PEng
Dept of Chemical & Biological Engineering tel: +1 608 262-3370
University of Wisconsin-Madison           fax: +1 608 262-5434
1415 Engineering Drive                    dyin at cae dot wisc dot edu
Madison WI 53706-1691 USA                 www.engr.wisc.edu/groups/mtsm/