- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Auto Trimming of log files
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
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
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
тАО01-12-2005 07:08 PM
тАО01-12-2005 07:08 PM
Auto Trimming of log files
I have written a script to capture activities on my system. However I am afraid that the log might grow too large in future.. Is there any ingenious way to write another script so as to check and delete the lines in the log that is say 30days old?
Thank u..
- Tags:
- trim logfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2005 07:23 PM
тАО01-12-2005 07:23 PM
Re: Auto Trimming of log files
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2005 07:33 PM
тАО01-12-2005 07:33 PM
Re: Auto Trimming of log files
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2005 07:39 PM
тАО01-12-2005 07:39 PM
Re: Auto Trimming of log files
you can write your own script to cut off lines when it's bigger than n lines or n MB.
But if you do not want to reinvent the wheel then have a loot at:
http://hpux.its.tudelft.nl/hppd/hpux/Sysadmin/logrotate-2.5/
regards,
Thierry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2005 07:50 PM
тАО01-12-2005 07:50 PM
Re: Auto Trimming of log files
Intead of using one file for all. My crontab script write out one file for one day. like this:
[TIAN:/] cat script/ia_start.sh
################# Applciation Start Script for cron file #################
#### Make the log_file ####
GetDate=`date +"%Y%m%d"`
LOG_NM=/script/log/ia_start/ia_start.$GetDate
echo "=====[Today is `date`] Application Start Script START...]=====" >> $LOG_NM
##------------------------ Oracle Start -----------------------------
echo " Firstly, Start Oracle : `date` " >> $LOG_NM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2005 07:59 PM
тАО01-12-2005 07:59 PM
Re: Auto Trimming of log files
1, Create mark point for each lines by this shell variable
GetDate=`date +"%d"`+"HenryChua"
2, at script you adding this variable to the end (or begin) OF each line.
3. at trimming script. you look for string:
30HenryChua and delete it.
tienna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2005 08:15 PM
тАО01-12-2005 08:15 PM
Re: Auto Trimming of log files
I would suggest creating a directory and writing one file per day, based on the day of the month.
This will automatically overwrite your log from one month ago and is very is to analyse.
./script > `date +"%d"`.log 2>&1
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2005 08:29 PM
тАО01-12-2005 08:29 PM
Re: Auto Trimming of log files
find $LOGDIR -name appllog\*.log -mtime +1 -exec /usr/contrib/bin/gzip {} \;
find $LOGDIR -name appllog\*.gz -mtime +31 -exec rm {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-14-2005 03:55 AM
тАО01-14-2005 03:55 AM
Re: Auto Trimming of log files
cat /dev/null > theLogFile
right after the save.
Some programs don't automatically create the log file if it isn't there.
As the others said, it's a lot easier to save the whole log file every 30 days (or however often makes sense) and start a new one, than try to pull out lines.
I usually save log file with names like
wtmp2004_12.gz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2005 09:03 AM
тАО01-16-2005 09:03 AM
Re: Auto Trimming of log files
Organising archives directories named by month and year means that archives can be easily removed one month at a time.
_________________
#!/bin/ksh
#
# retarc - RETire and ARChive
#
# files in the specified directory which are over a certain size are
# 1) renamed to filename.date
# 2) compressed
#
# Author: Daavid June 1, 2000
yearStr=`date +"%E"`
monthStr=`date +"%m"`
dayTimeStr=`date +"%d_%H_%M"`
archiveDir="archive"
dest=
startDir=$1
if test -z "$2"; then
# 20 Mb
minSize=20971520
else
minSize=$2
fi
if test -z "$startDir"; then
echo "Usage : $0 dirName [minFileSize]"
echo " where dirName is the location of files to be retired and archived"
echo " minFileSize is the minimum file size in bytes to be processed."
echo " (default is $minSize bytes)"
else
# Ok - time for action, first make sure the correct dir exists
dest="${startDir}/$archiveDir"
mkdir $dest > /dev/null 2>&1
dest="${dest}/$yearStr"
mkdir $dest > /dev/null 2>&1
dest="${dest}/$monthStr"
mkdir $dest > /dev/null 2>&1
for file in `ls $startDir`
do
if test -n {`echo $file | grep "\.Z\$"`} ; then
cd $startDir
if test -f $file ; then
size=`ls -sn1 $file | awk '{ print \$6 }'`
if (( $size > $minSize )) ; then
cp $file $dest/$file.$dayTimeStr
if (( $? == 0 ))
then
# 'zero' the original
>$file
compress $dest/$file.$dayTimeStr
else
echo "Copy Failed!"
fi
fi
fi
fi
done
fi