- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- search syslog for errors with perl
Operating System - HP-UX
1822193
Members
3993
Online
109640
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО12-18-2002 08:25 AM
тАО12-18-2002 08:25 AM
Hi
I have a perl script which searches syslog for error message.In this case i have just used "vmunix" but what i want to be able to do is only list error's for set date.
For example if i run script now it will only check for messages in the last 24 hours.
Regards
Simon
I have a perl script which searches syslog for error message.In this case i have just used "vmunix" but what i want to be able to do is only list error's for set date.
For example if i run script now it will only check for messages in the last 24 hours.
Regards
Simon
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2002 10:13 AM
тАО12-18-2002 10:13 AM
Re: search syslog for errors with perl
hi,
If you only wanna see entries
of today
grep $(date | awk '{print $2,$3}') /var/adm/syslog/syslog.log
But maybe it is better you
make a script that renames
your logfiles on daily base.
rgds.
Steven
If you only wanna see entries
of today
grep $(date | awk '{print $2,$3}') /var/adm/syslog/syslog.log
But maybe it is better you
make a script that renames
your logfiles on daily base.
rgds.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2002 02:04 PM
тАО12-18-2002 02:04 PM
Solution
Hi Simon,
INAPH
(I'm Not A Perl Hacker)
but I'll give it a try.
I don't know which version of Perl you're using, so I'll try and keep it simple (and backwards compatible with Perl 4, I hope)...
-----------------------
#!/usr/contrib/bin/perl
@months = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" );
($day,$month,$string)=@ARGV[0,1,2];
open(LOGFILE,"while() {
/^$months[$month-1]\s+$day\s+.*$string/ && print;
}
close(LOGFILE);
-------------------------
The syntax on the command prompt is:
#scriptname
e.g.
#logsearch 18 12 vmunix
will yield all entries in the syslog of December 18th containing the string "vmunix". Note that you should put quotes around a search string that contains white space...
I'm sure procura will come up with a better script, but that's the essence of Perl: there's more than one way to do it :-)
Hope this helps.
Regards,
Vincent
INAPH
(I'm Not A Perl Hacker)
but I'll give it a try.
I don't know which version of Perl you're using, so I'll try and keep it simple (and backwards compatible with Perl 4, I hope)...
-----------------------
#!/usr/contrib/bin/perl
@months = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" );
($day,$month,$string)=@ARGV[0,1,2];
open(LOGFILE,"while(
/^$months[$month-1]\s+$day\s+.*$string/ && print;
}
close(LOGFILE);
-------------------------
The syntax on the command prompt is:
#scriptname
e.g.
#logsearch 18 12 vmunix
will yield all entries in the syslog of December 18th containing the string "vmunix". Note that you should put quotes around a search string that contains white space...
I'm sure procura will come up with a better script, but that's the essence of Perl: there's more than one way to do it :-)
Hope this helps.
Regards,
Vincent
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP