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

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



On 3/7/06, Zachary Miller <zmiller@xxxxxxxxxxx> wrote:
> On Tue, Mar 07, 2006 at 02:21:14PM -0600, 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?
>
> no, not with condor_q itself.  you'll need a wrapper script to pretty-print
> the times and dates.

in the spirit of De-Wei's contribution

awk: (gawk to be precise - not tested on anything else) the example
shows bash input but you could get it any other way you like

condor_q ${OPTIONS} \
-format "%d|" ClusterId \
-format "%d|" ProcId \
-format "%s|" Owner \
-format "%d|" QDate \
-format "%d|" EnteredCurrentStatus \
-format "%d|" ServerTime \
-format "%d|" JobStatus \
-format "%d|" JobPrio
-format "?%d\n" ClusterId | awk '
BEGIN {
	FS = "|";
}
{
	ClusterId = $1 ;
	ProcId = $2;
	JobId = ClusterId "." ProcId;
	Owner = $3;	
	QDate = $4;
	EnteredCurrentStatus = $5;
	ServerTime = $6;
	JobStatus = $7;	
	JobPrio = $8;

	# these are assuming all previous execution runs were useless
	RunTime = strftime("%H:%M:%S", ServerTime - EnteredCurrentStatus);
	RunDays = (ServerTime - EnteredCurrentStatus) / 86400;
	sprintf("%-9s %1d+%s %-2d\n",
		JobId,
		RunDays,
		RunTime,
		JobPrio);
}
'

Matt