- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- need help on ksh scripting
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2003 10:11 PM
10-09-2003 10:11 PM
need help on ksh scripting
Does anyone have any good suggestion on calculating the duration for the data below using ksh scripts? I am think of using year, month, day, hour and minute for comparison to find the duration. Does anyone have any good suggestion such as using awk, sed, sort, etc..
08/22/02|00:00| 300| 100| <---- 1st duration
09/22/02|00:05| 299| 100| <---- 2nd duration
09/22/02|00:10| 299| 100|
11/12/02|00:15| 300| 100| <---- 3rd duration
12/30/02|23:50| 299| 100| <---- 4th duration
12/31/02|23:50| 299| 100| <---- 5th duration
12/31/02|23:55| 299| 100|
01/01/03|00:00| 299| 100|
01/01/03|00:05| 299| 100|
01/01/03|00:35| 299| 100| <---- 6th duration
02/19/03|00:40| 300| 100| <---- 7th duration
03/03/03|00:45| 299| 100| <---- 8th duration
03/03/03|00:50| 299| 100|
03/11/03|00:55| 299| 100| <---- 9th duration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2003 10:21 PM
10-09-2003 10:21 PM
Re: need help on ksh scripting
Please explain the data format.
After that it should be easy with awk -F"|"
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2003 10:36 PM
10-09-2003 10:36 PM
Re: need help on ksh scripting
1st col is date in mm/dd/yy
2nd col is 24hrs time in hh:mm
3rd col is data
4th col is also max CPU%
i need to output the report of the duration of the max data e.g.
Start 12/31/02 23:50 and End 01/01/03 00:05 - 15minutes when CPU% is at max
Start 01/01/03 00:05 - 5 minutes when CPU% is max
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2003 10:55 PM
10-09-2003 10:55 PM
Re: need help on ksh scripting
Every time col 3 changes you want a report of the time since it last changed.
This is not trivial with awk and I'm no Perl wizard.
I suggest you wait a couple of hours until the US comes online, and Clay will solve your problem with his caljd script.
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2003 10:24 AM
10-10-2003 10:24 AM
Re: need help on ksh scripting
The syntax to do this w/ the Gnu date command is:
date -d "mm/dd/yy HH:MM:SS" +%s
From your example:
12/31/02|23:55| 299| 100|
01/01/03|00:00| 299| 100|
01/01/03|00:05| 299| 100|
01/01/03|00:35| 299| 100| <---- 6th duration
In your example 12/31/02 23:55 is equal to 1,041,400,500 seconds since epoch. And 01/01/03 00:35 is 1,041,402,900 seconds since epoch. Subtract the prior from the later and you get 2,400 seconds duration that it was at 299. You can then just roll up the 2,400 to days, hours, minutes, seconds by dividing it out.
1 day = 86,400 seconds
1 hour = 3,600 seconds
1 minute = 60 seconds (of course)
So 2,400 seconds is 40 minutes.
Gnu Date is part of sh_utils on the HP Porting and archive center.
http://hpux.cs.utah.edu/hppd/hpux/Gnu/sh_utils-2.0/
Hope that helps!
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2003 07:29 PM
10-10-2003 07:29 PM
Re: need help on ksh scripting
or
you could use perl and as suggested in the previous post, use the localtime and timelocal functions to convert your dates to seconds from the epoch, do your arthimetic, and format to your desired output