1845564 Members
2598 Online
110245 Solutions
New Discussion

Re: syslog.log

 
Feljav
Frequent Advisor

syslog.log

The file syslog.log grow without restrictions?
Can be controlled its growth, that is not manually?
9 REPLIES 9
Pete Randall
Outstanding Contributor

Re: syslog.log

Whenever you reboot, a copy of syslog is made to /var/adm/syslog/OLDsyslog.log and /var/adm/syslog/syslog.log starts out fresh. You could also do this same thing with a cron job, once a week, or once a month or so.


Pete

Pete
Victor BERRIDGE
Honored Contributor

Re: syslog.log

Hi,

Yes, by the use of a tool such as rotatelog...
http://www.interhack.net/projects/rotatelog/


All the best
Victor
Sp4admin
Trusted Contributor

Re: syslog.log

Hi Feljay,

I think Pete has it covered. On reboot the syslog whiches to OLDsyslog.log. Like Pete said you could create a cron job to cat /dev/null the log. How often do you reboot your server? I would'nt want to ran a cron job on syslog. But if you feel the need then it's possiable.

sp,
Mark Nieuwboer
Esteemed Contributor

Re: syslog.log

Hi Feljav,

Sorry to say but to reboot to clear syslog is not the idea of unix it is not windows.
just trim the log file. see http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=991878

our stop and start the syslog daemon you have the same result as a reboot.

grtz. Mark
spex
Honored Contributor

Re: syslog.log

Hi,

# crontab -l | grep archive_logs
59 23 * * * /home/root/archive_logs-daily.sh

# cat archive_logs-daily.sh
#!/usr/bin/sh
DATE=$(date +%Y%m%d)
###############################
# syslog
###############################
cd /var/adm/syslog
[ -f syslog.yester.log ] && rm -f syslog.yester.log
mv syslog.log syslog.${DATE}.log
ln -s syslog.${DATE}.log syslog.yester.log
find /var/adm/syslog -name '*.log' -mtime +90 -print | xargs rm -f
# Archive/rotate other logs here...
exit

PCS
Jeff Wilkins
Valued Contributor

Re: syslog.log

#!/sbin/sh
#
# This script file will dynamically assign a new filename, using the current
# datestamp, to the logfile definitions specified in the syslog configuration
# file.
#
###############################################################################
#

CFG_CURR=/etc/syslog.conf
CFG_LAST=/etc/syslog.conf.last
CFG_MSTR=/etc/syslog.conf.master

if [ -e ${CFG_LAST} ]; then /usr/bin/rm -f ${CFG_LAST} > /dev/null 2>&1 ; fi

/usr/bin/mv -f ${CFG_CURR} ${CFG_LAST}

/usr/bin/sed -e "s/\$DATE/`/usr/bin/date +%Y%m%d`/" ${CFG_MSTR} > ${CFG_CURR}

if [ -e ${CFG_CURR} ]; then /usr/bin/kill -s SIGHUP `/usr/bin/cat /var/run/syslog.pid`; fi

/usr/bin/compress -f `/usr/bin/grep "/var/adm/syslog/" ${CFG_LAST} | /usr/bin/sed -e "s/^.*\/var/\/var/"`

/usr/bin/find /var/adm/syslog/ -name *.Z -a ! -mtime -7 -exec /usr/bin/rm {} \;

#
#
###############################################################################

pg /etc/syslog.conf
# @(#) $Revision: 74.1 $
#
# syslogd configuration file.
#
# See syslogd(1M) for information about the format of this file.
#
*.info /var/adm/syslog/syslog_20061113.log
*.alert /dev/console
*.alert root
*.emerg *

/etc/syslog.conf.last same except
*.info /var/adm/syslog/syslog_20061112.log

/etc/syslog.conf.master same except
*.info /var/adm/syslog/syslog_$DATE.log

then run a cron to start the script at midnight
jfwilkins@hotmail.com
Jeff Wilkins
Valued Contributor

Re: syslog.log

for a little more explaination -
new log with date every day
compress yesterdays log
remove logs after 7 days
if you don't want them removed - uncompress them
jfwilkins@hotmail.com
Rory R Hammond
Trusted Contributor

Re: syslog.log

rebooting to switch syslog is a bad Idea. I have systems that have been up for over a year.
The trick is to manage the logs.

I use a program called savelog which is similar to logrotate.

Caution about syslog.log. It is always open by syslogd. deleting syslog.log will not free up space. Basically I copy syslog.log to a backup name and zero out syslog.log with
echo > syslog.log
On my systems I zero out syslog.log weekly and keep 7 copies (7 weeks).
There are a 100 ways to do things and 97 of them are right
dirk dierickx
Honored Contributor

Re: syslog.log

i suggest logrotate, it works great and does some extra things as well which you might find
handy.

hpux depot can be found here:
http://hpux.connect.org.uk/hppd/hpux/Sysadmin/logrotate-2.5/