- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Grep file contents by date
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
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
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
07-07-2016 03:25 AM
07-07-2016 03:25 AM
Grep file contents by date
Hi,
I need to calculate uptime for an application SAP, example is the contents of a file called VMCavailable.log
07.07.2016 03:12:55 available: 0000s/3601s SGC: 0000s
07.07.2016 04:12:56 available: 0000s/3601s SGC: 0000s
07.07.2016 05:12:57 available: 0000s/3600s SGC: 0000s
07.07.2016 06:12:57 available: 0000s/3601s SGC: 0000s
07.07.2016 07:12:58 available: 0000s/3600s SGC: 0000s
07.07.2016 08:12:58 available: 0000s/3601s SGC: 0000s
07.07.2016 09:12:59 available: 0000s/3601s SGC: 0000s
07.07.2016 10:13:00 available: 0000s/3600s SGC: 0000s
07.07.2016 11:13:00 available: 0000s/2220s SGC: 0000s
When system is down it is indicated as such:
10.04.2016 21:09:35 system down 105s
04.05.2016 06:46:40 system down 1728000s
24.06.2016 20:00:34 system down 115s
24.06.2016 21:08:33 system down 89s
The previous guy's document had the following command penned:
more VMCavailable.log |grep month.year
This does not actually yield any results, sorry I know this is a stupid query. But I need this information rather urgently.
echo $TERM
vt100
echo $SHELL
/usr/bin/csh
version: Release: HP-UX B.11.31
Regards,
Johan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2016 08:42 AM
07-07-2016 08:42 AM
Re: Grep file contents by date
> more VMCavailable.log |grep month.year
>
> This does not actually yield any results, [...]
Not a very useful problem description. What, exactly, was the
command which you used? What, exactly, happened when you used it?
"more" on the front end (like that) makes little sense to me. More
reasonable:
grep month.year VMCavailable.log
or, if that gives you too much output, use "more" on the back end:
grep month.year VMCavailable.log | more
> I need to calculate uptime [...]
I'd need a better explanation of exactly what you want to calculate,
from what, to offer any suggestions on that.
> version: Release: HP-UX B.11.31
Actual output from "uname -a" would be more informative/reliable.
> [...] stupid query.
Elementary, perhaps. It's not the same thing. Missing useful info
is a bigger problem. As usual, showing actual commands with their
actual output can be more helpful than vague descriptions or
interpretations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2016 09:17 PM - edited 07-08-2016 09:17 PM
07-08-2016 09:17 PM - edited 07-08-2016 09:17 PM
Re: grep file contents by date
>more VMCavailable.log | grep month.year
(I assume he meant you to replace month and year by the actual values.)
If you want all the lines for July 2016 you can use:
fgrep 07.2016 VMCavailable.log
Once you get that output, you need to use your business logic to compute your "uptime".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2016 08:50 PM
07-17-2016 08:50 PM
Re: Grep file contents by date
This command could get you the down time for the current month, you can modify it for the up times.
awk "/^.{2}$(date +%m.%Y).*down/{d+=int(\$NF)}END{print d}" < VMCavailable.log
A good first step could be understanding exactly what the information in the log means and exactly what this command is trying to do.
--
ranga