- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- log house keeping
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
04-28-2008 05:38 AM
04-28-2008 05:38 AM
I am performing log house keeping and want to keep all entries after the first of April ...
how can I cat out all information from April?
the log is appended everytime something is writing and has the time stamp at the begining of the entry.
I was just wondering is there a specific command that can do this?
thanks
Chris.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2008 05:51 AM
04-28-2008 05:51 AM
SolutionI would use logrotate to copy the logs to a new location the first of every month.
http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/logrotate-2.5/
The code here is a little old and may need adjustment. I recall a thread that said in order to get this to work on HP-UX you may need to compile the code.
Logrotate, a standard par to of Linux is worth the effort to install, because its so helpful.
Alternate:
scripts that back up the log file and then > logfile name, run by cron the first of the month.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2008 06:32 AM
04-28-2008 06:32 AM
Re: log house keeping
Then add it to cron
#!/usr/bin/ksh
#Use cron to schedule on the 1st of every month
typeset -i i=1
mv ./log1 ./log2
mv ./log2 ./log3
mv ./log3 ./log4
mv ./log4 ./log5
mv ./log5 ./log6
cp ./newlog ./log1
echo "Starting new log" > ./newlog
Customize to suit your needs.
Don't move syslog as you'll break the daemon.
Redirect to it as I did with newlog above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2008 07:04 AM
04-28-2008 07:04 AM
Re: log house keeping
ie I find a logfile that is xxx days old and I want to keep say 60 days of data and I cannot shut down the app so the logfile remains active but is written to every 20 minutes or so.
Chris.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2008 01:47 AM
04-29-2008 01:47 AM
Re: log house keeping
If the logfile is kept open, there is not much you can do if the app is continually writing to the end of the file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2008 02:10 AM
04-29-2008 02:10 AM
Re: log house keeping
at the risk of losing some log information, you can also implement the following command:
cp -p
e.g.
cp -p mylog.log mylog.log.$(date +%y%m%d-%H%M); cat /dev/null > mylog.log
hope this helps!
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2008 02:36 AM
04-29-2008 02:36 AM
Re: log house keeping
you may also schedule this using the CRON.
e.g.
#*******************************************************************************
# min|hour |day |month|day |script
# | |of mo| |of wk|
#----|-----|-----|-----|-----|--------------------------------------------------
#*******************************************************************************
#
#****
# Log maintenance Every 2 months
#****
00 05 30 1,3,5,7,9,11 * cp -p mylog.log mylog.log.$(date +\%y\%m\%d-\%H\%M); cat /dev/null > mylog.log
#*******************************************************************************
# END OF TABLE day0->Sunday day6->Saturday
#*******************************************************************************
(you will to implement the cleanup scripts accordingly - so that the archived logfiles are purged at the desired interval)
hope this helps too!
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2008 03:38 AM
04-29-2008 03:38 AM
Re: log house keeping
Other replies already covered some methods
to help with log file rotation.
May I add some more, not necessarily
direclty written for HP-UX but quite
portable and should help:
a) HP-UX Porting site has another one
(albeit a bit old too):
http://gatekeep.cs.utah.edu/hppd/hpux/Sysadmin/smartlog-3.5/
At least, both smartlog and logrotate
come with the sources...
b) Scripts based on Perl modules like
Logfile-Rotate
c) Replace standard syslog daemon with
syslog-ng
d) Bill Hassell (our very knowledgeable
colleague and long-term ITRC member)
has logtrim:
http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=1053445&admit=109447627+1209468059756+28353475
e) An example based on Sun's generic Shell
script that you can modify to suit your
needs, or at least learn from it:
#!/bin/sh
#
# Copyright(c) 1997, by Sun Microsystems, Inc.
#
LOG=messages
cd /var/adm
test -f $LOG.2 && mv $LOG.2 $LOG.3
test -f $LOG.1 && mv $LOG.1 $LOG.2
test -f $LOG.0 && mv $LOG.0 $LOG.1
mv $LOG $LOG.0
cp /dev/null $LOG
chmod 644 $LOG
#
LOGDIR=/var/adm
LOG=syslog
if test -d $LOGDIR
then
cd $LOGDIR
if test -s $LOG
then
test -f $LOG.6 && mv $LOG.6 $LOG.7
test -f $LOG.5 && mv $LOG.5 $LOG.6
test -f $LOG.4 && mv $LOG.4 $LOG.5
test -f $LOG.3 && mv $LOG.3 $LOG.4
test -f $LOG.2 && mv $LOG.2 $LOG.3
test -f $LOG.1 && mv $LOG.1 $LOG.2
test -f $LOG.0 && mv $LOG.0 $LOG.1
mv $LOG $LOG.0
cp /dev/null $LOG
chmod 644 $LOG
sleep 40
fi
fi
#
kill -HUP `cat /etc/syslog.pid`
f) Many Shell scripts, like:
http://www.zazzybob.com/bin/logrevolver.sh.html
g) There is also a BASH script called
logrotate:
http://iain.cx/src/logrotate/
h) Freshmeat project newsyslog:
http://freshmeat.net/projects/newsyslog/
A bit of creativity goes a log way :)
I hope this helps a bit...
Cheers,
VK2COT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2008 07:01 AM
04-29-2008 07:01 AM
Re: log house keeping
DATE=`date +%m%d%y`
ARCH=
# Roll over syslog.log
#
cd /var/adm/syslog
umask 022
cp syslog.log log.last
cp /dev/null syslog.log
/bin/kill -HUP `/bin/cat /var/run/syslog.pid`
uniq log.last $ARCH/syslog.${DATE}
rm log.last
#
NOTE: This way I can search all log files for a given month using one grep command. Since the month is the first two digits all I have to do is grep on syslog.04???? for all of Aprils syslog files.
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2008 06:12 AM
05-07-2008 06:12 AM