10-07-2009
Date comparison with 'string date having slashes and time zone' in Bash only
1. The problem statement, all variables and given/known data:
I have standard web server log file. It contains different columns (like IP address, request result code, request type etc) including a date column with the format [31/Mar/2002:19:30:41 +0200].
I have developed a log analysis command line utility that displays different statistics from the log (like the IP with most connection attempts, the most common result codes etc.). In fact to view every stat the user will have to give a specific switch to my utility.
Now comes the problem; with every stat the user can ask to display the results for either 1. previous n hours. or 2. previous n days. I am unable to use the date from the file with format [31/Mar/2002:19:30:41 +0200] and make a comparison with the timestamp of previous n hours or previous n days.
Constraint: I have to attempt this is only in bash.
2. School (University) and Course Number:
Blekinge Institute of Technology
MS Computer Science
10 More Discussions You Might Find Interesting
1. Tips and Tutorials
The GNU date command in full of goodies but not when it comes to calculate a date or time difference. Here is what I came up with after looking to more than one solution.
Code should be self explaining.
#!/bin/bash
date2stamp () {
date --utc --date "$1" +%s
}
stamp2date (){
... (0 Replies)
Discussion started by: ripat
0 Replies
2. Shell Programming and Scripting
I have a CSV (comma separated vaule) file whose entries resemble
Area,\\ntsvsp02\vmcs\download\files\Areas.dat,1,20090303,0,Import Complete,2009-03-02 04:23:00
Product,\\ntsvsp02\vmcs\download\files\items.dat,1,20090303,0,Import Complete,2009-03-02 04:23:00... (3 Replies)
Discussion started by: zainravi
3 Replies
3. Shell Programming and Scripting
Hi
I have this simple script:
#!/bin/bash
date1=2009:07:15:12:36
date2=2009:07:15:12:16
echo $date1
echo $date2
datediff=
#datediff=date1-date2
echo datediff is$datediff
How do i return the difference in seconds? (6 Replies)
Discussion started by: carp.dk
6 Replies
4. Shell Programming and Scripting
Hi,
We have a server in US and hence while the command "date" is given it gives the output in EDT. If I want the date output in MET, how can I get it. Please let me know how I could do it in the script which is ksh. Thanks. (1 Reply)
Discussion started by: jmathew99
1 Replies
5. Shell Programming and Scripting
Hi,
I'm having two fields in the file
F1|F2
20111220|102000
F1 ->YYYYMMDD
F2 ->HHMMSS
Now, I need to compare this with current date & time and need to return the difference value in hours. Already, I checked with datecalc from the forum. So, need hints from Shell Gurus.
Thanks (10 Replies)
Discussion started by: buzzusa
10 Replies
6. Shell Programming and Scripting
Hi
Summary:
- Script will take 2 arguments
- Argument 1: Date/Time value in a particular format
- Argument 2: TimeZone value
Examples:
Argument 1:
a. "May 11, 2012 08:00:00 AM"
b. "Dec 21, 2012 12:21:12 PM"
c. "Oct 2, 2012 05:00:00 PM"
Argument 2:
a. MT or MST or MDT
b. ET
c.... (4 Replies)
Discussion started by: anuragpgtgerman
4 Replies
7. UNIX for Dummies Questions & Answers
I'd like to convert a date string in the form of sun aug 19 09:03:10 EDT 2012, to unixtime timestamp using awk.
I tried
This is how each line of the file looks like, different date and time in this format
Sun Aug 19 08:33:45 EDT 2012, user1(108.6.217.236) all: test on the 17th
... (2 Replies)
Discussion started by: bkkid
2 Replies
8. Solaris
I have a cluster of two Solaris server (veritas cluster). one working and the other is standby
I am going to change the date on them , and am looking for a secure solution as it is giving an important service.
my opinion is that the active one doesn't need to be restarted (if I don't change the... (1 Reply)
Discussion started by: barry1946
1 Replies
9. Shell Programming and Scripting
I'm looking for a way to have the "date" command output the date in a specific format.
I'm not familiar with the different ways to use the date command at all. i read up on it, but i dont get how to manipulate it.
i know that i can get the date format to give me a format like:
2012-10-13... (6 Replies)
Discussion started by: SkySmart
6 Replies
10. Shell Programming and Scripting
I am trying to convert local time to time in Ireland. Instead it is going the opposite direction (taking the local time as it if were in Ireland and displaying that the time would be here).
$ echo "$TZ"; date; date --date='TZ="Europe/Dublin" '"$(date)"
America/Phoenix
Mon, Apr 13, 2015... (7 Replies)
Discussion started by: Michael Stora
7 Replies
LEARN ABOUT DEBIAN
condor_userlog
condor_userlog(1) General Commands Manual condor_userlog(1)
Name
condor_userlog Display - and summarize job statistics from job log files.
Synopsis
condor_userlog [-help] [-total | -raw] [-debug] [-evict] [-j cluster | cluster.proc] [-all] [-hostname] logfile ...
Description
condor_userlog parses the information in job log files and displays summaries for each workstation allocation and for each job. See the
manual page for condor_submiton page for instructions for specifying that Condor write a log file for your jobs.
If -totalis not specified, condor_userlogwill first display a record for each workstation allocation, which includes the following informa-
tion:
Job
The cluster/process id of the Condor job.
Host
The host where the job ran. By default, the host's IP address is displayed. If -hostnameis specified, the host name will be displayed
instead.
Start Time
The time (month/day hour:minute) when the job began running on the host.
Evict Time
The time (month/day hour:minute) when the job was evicted from the host.
Wall Time
The time (days+hours:minutes) for which this workstation was allocated to the job.
Good Time
The allocated time (days+hours:min) which contributed to the completion of this job. If the job exited during the allocation, then this
value will equal ``Wall Time.'' If the job performed a checkpoint, then the value equals the work saved in the checkpoint during this
allocation. If the job did not exit or perform a checkpoint during this allocation, the value will be 0+00:00. This value can be greater
than 0 and less than ``Wall Time'' if the application completed a periodic checkpoint during the allocation but failed to checkpoint
when evicted.
CPU Usage
The CPU time (days+hours:min) which contributed to the completion of this job.
condor_userlogwill then display summary statistics per host:
Host/Job
The IP address or host name for the host.
Wall Time
The workstation time (days+hours:minutes) allocated by this host to the jobs specified in the query. By default, all jobs in the log are
included in the query.
Good Time
The time (days+hours:minutes) allocated on this host which contributed to the completion of the jobs specified in the query.
CPU Usage
The CPU time (days+hours:minutes) obtained from this host which contributed to the completion of the jobs specified in the query.
Avg Alloc
The average length of an allocation on this host (days+hours:minutes).
Avg Lost
The average amount of work lost (days+hours:minutes) when a job was evicted from this host without successfully performing a checkpoint.
Goodput
This percentage is computed as Good Time divided by Wall Time.
Util.
This percentage is computed as CPU Usage divided by Good Time.
condor_userlogwill then display summary statistics per job:
Host/Job
The cluster/process id of the Condor job.
Wall Time
The total workstation time (days+hours:minutes) allocated to this job.
Good Time
The total time (days+hours:minutes) allocated to this job which contributed to the job's completion.
CPU Usage
The total CPU time (days+hours:minutes) which contributed to this job's completion.
Avg Alloc
The average length of a workstation allocation obtained by this job in minutes (days+hours:minutes).
Avg Lost
The average amount of work lost (days+hours:minutes) when this job was evicted from a host without successfully performing a checkpoint.
Goodput
This percentage is computed as Good Time divided by Wall Time.
Util.
This percentage is computed as CPU Usage divided by Good Time.
Finally, condor_userlogwill display a summary for all hosts and jobs.
Options
-help
Get a brief description of the supported options
-total
Only display job totals
-raw
Display raw data only
-debug
Debug mode
-j
Select a specific cluster or cluster.proc
-evict
Select only allocations which ended due to eviction
-all
Select all clusters and all allocations
-hostname
Display host name instead of IP address
General Remarks
Since the Condor job log file format does not contain a year field in the timestamp, all entries are assumed to occur in the current year.
Allocations which begin in one year and end in the next will be silently ignored.
Exit Status
condor_userlogwill exit with a status value of 0 (zero) upon success, and it will exit with the value 1 (one) upon failure.
Author
Condor Team, University of Wisconsin-Madison
Copyright
Copyright (C) 1990-2012 Condor Team, Computer Sciences Department, University of Wisconsin-Madison, Madison, WI. All Rights Reserved.
Licensed under the Apache License, Version 2.0.
See the Condor Version 7.8.2 Manualor http://www.condorproject.org/licensefor additional notices. condor-admin@cs.wisc.edu
September 2012 condor_userlog(1)