- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- shell script for checking if the system logs are u...
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
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
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
тАО12-25-2007 10:48 PM
тАО12-25-2007 10:48 PM
I need to write a shell script for checking if the system logs are updating.
Sometimes it so happens that someone changes the configuration in syslog.conf due to which the logging stops.
I want to run a monthly script which will check if the log files are updating..
How can i achieve this.
Regards
Sunny
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-26-2007 02:07 AM
тАО12-26-2007 02:07 AM
Solution$ find /var/adm/syslog/syslog.log -mtime -7
If you don't get any output, then the file hasn't changed in 7 days.
If you only care about since the last time your ran your script, you can touch a reference file and then compare that with the current logfile with this syntax:
if [ logfile -nt ref_file ]; then
echo "logfile is newer"
else
echo "logfile hasn't been updated"
fi
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-26-2007 02:17 AM
тАО12-26-2007 02:17 AM
Re: shell script for checking if the system logs are updating
Thanks for your response.
The find command just skipped out of my mind.
This will solve my purpose.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-26-2007 02:23 AM
тАО12-26-2007 02:23 AM
Re: shell script for checking if the system logs are updating
save file line count to another file and check every 15 ( for example ) minutes for line count .
for example
linecnt=`cat /test/syslog.filecnt`
file=/usr/adm/syslog/syslog.dated
newcnt=`cat $file | wc -l`
if [ $newcnt -gt $linecnt ] ; then
let diff=$newcnt-$filecnt
cat $file | tail -${diff} > difffile
fi
echo $newcnt > /test/syslog.filecnt
check for write mistakes.
Hasan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-26-2007 11:26 AM
тАО12-26-2007 11:26 AM
Re: shell script for checking if the system logs are updating
why don't you check that the file has been updated with it's timestamp mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-26-2007 08:51 PM
тАО12-26-2007 08:51 PM
Re: shell script for checking if the system logs are updating
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-26-2007 10:10 PM
тАО12-26-2007 10:10 PM
Re: shell script for checking if the system logs are updating
The fact mentioned by "blah2blah" about syslogd won't work for me. I have a bunch of log files which i have to check.
Yes. Even i thought 1 month is too long to check if anything is wrong with syslog.conf
May be i can run the script weekly.
Anyways thanks for your valuable suggestions.
REgards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2007 05:32 AM
тАО12-27-2007 05:32 AM
Re: shell script for checking if the system logs are updating
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2007 05:54 AM
тАО12-27-2007 05:54 AM
Re: shell script for checking if the system logs are updating
The purpose of the script is to check if all the log files (selected ones) are present and if they are getting updated.
This script is going to be deployed on all kind of servers, production, development, archieve, backup etc...
So there will some files which may not get updated for some period of time.
Hence planning for a weekly check.
This is what the person who is going to audit the server has asked for.
The contents which are logging to syslog and other log files depend upon the correct configuration of syslog.conf. And this is a different point to look at..
However i have noted the points you mentioned. :)
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2007 06:07 AM
тАО12-27-2007 06:07 AM
Re: shell script for checking if the system logs are updating
For completeness, look at /var/adm for all the other logfiles that are kept on your system.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2007 07:39 AM
тАО12-27-2007 07:39 AM
Re: shell script for checking if the system logs are updating
Here's another way to verify that a file is being updated. This one-liner will return one (1) to denote failure and zero (0) to denote an updated file, exactly like any standard Unix command would be expected to do. You can than construct any logic around that that you need.
# perl -le 'exit 1 if -M "/var/adm/syslog/syslog.log" > 3600/86400'
This tests then named file's modification timestamp. In this example, the script exits with one (1) if the "syslog.log" has *not* been updated in more than *one_hour* (60 seconds times 60 minutes) of a day (60 seconds times 60 minutes times 24 hours).
Nothing more is needed --- no temporary files nor complex logic.
Regards!
...JRF...
- Tags:
- Perl