LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Log rotation for DHCP (https://www.linuxquestions.org/questions/linux-newbie-8/log-rotation-for-dhcp-914029/)

Kohlu 11-17-2011 07:28 AM

Log rotation for DHCP
 
Hi

I have a DHCP server working fine with me however its log file is excessively big I have heard there is an option of log rotation any idea how can it be implemented on a linux/solaris DHCP server.

davemguru 11-17-2011 08:04 AM

Quote:

Originally Posted by Kohlu (Post 4526486)
Hi

I have a DHCP server working fine with me however its log file is excessively big I have heard there is an option of log rotation any idea how can it be implemented on a linux/solaris DHCP server.

there is a linux command "logrotate" which is (typically) run automagically for you. All you would need to do is add the path of the dhcp log file that you want trimmed/archived/rotated to the logrotate configuration file.
I respectfully suggest you try the man page for the command http://linuxcommand.org/man_pages/logrotate8.html
This has a sample logrotate configuration file in it - which (I hope) will solve your problem.
Dave

agentbuzz 11-17-2011 08:10 AM

Your /etc/logrotate.d/syslog should be changed on the syslog host to look like the following. This ensures that the DHCP logs are properly rotated and compressed, and that enough historical log data is retained for forensic purposes. You can add the path and name of the DHCP log to /etc/logrotate.d/syslog. Restart the syslogd or rsyslogd after you do this. Below is what the file might look like in your case.
Code:

/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron /var/log/dhcp/dhcp.log {
    daily
    missingok
    rotate 26
    compress
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    Endscript
        }


Kohlu 11-17-2011 12:32 PM

Thanks for the reply well the issue is that I am running DHCP on solaris

"SunOS 5.10 Generic_127127-11 sun4v sparc SUNW,Netra-T2000"


and i cant find the logrotate file anywhere how do I go ahead.

agentbuzz 11-17-2011 12:48 PM

Solaris log rotation
 
in Solaris it's logadm.conf. Also, the DHCP log is in /var/adm on Solaris and not /var/log

Kohlu 11-17-2011 01:24 PM

well this is how my logadm.conf looks like,how do I go ahead and will I have to make empty files and where for the logs to get transferred and what about the script to be used if any


"/etc/logadm.conf" 35 lines, 1515 characters
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "@(#)logadm.conf 1.7 07/01/10 SMI"
#
# logadm.conf
#
# Default settings for system log file management.
# The -w option to logadm(1M) is the preferred way to write to this file,
# but if you do edit it by hand, use "logadm -V" to check it for errors.
#
# The format of lines in this file is:
# <logname> <options>
# For each logname listed here, the default options to logadm
# are given. Options given on the logadm command line override
# the defaults contained in this file.
#
# logadm typically runs early every morning via an entry in
# root's crontab (see crontab(1)).
#
/var/log/syslog -C 8 -P 'Tue Nov 15 22:10:00 2011' -a 'kill -HUP `cat /var/run/s
yslog.pid`'
@
"/etc/logadm.conf" 35 lines, 1515 characters
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "@(#)logadm.conf 1.7 07/01/10 SMI"
#
# logadm.conf
#
# Default settings for system log file management.
# The -w option to logadm(1M) is the preferred way to write to this file,
# but if you do edit it by hand, use "logadm -V" to check it for errors.
#
# The format of lines in this file is:
# <logname> <options>
# For each logname listed here, the default options to logadm
# are given. Options given on the logadm command line override
# the defaults contained in this file.
#
# logadm typically runs early every morning via an entry in
# root's crontab (see crontab(1)).
#
/var/log/syslog -C 8 -P 'Tue Nov 15 22:10:00 2011' -a 'kill -HUP `cat /var/run/syslog.pid`'
/var/adm/messages -C 4 -P 'Fri Nov 11 22:10:00 2011' -a 'kill -HUP `cat /var/run/syslog.pid`'
/var/cron/log -P 'Wed Nov 16 22:10:00 2011' -c -s 512k -t /var/cron/olog
/var/lp/logs/lpsched -C 2 -N -t '$file.$N'
/var/fm/fmd/errlog -M '/usr/sbin/fmadm -q rotate errlog && mv /var/fm/fmd/errlog.0- $nfile' -N -s 2m
/var/fm/fmd/fltlog -A 6m -M '/usr/sbin/fmadm -q rotate fltlog && mv /var/fm/fmd/fltlog.0- $nfile' -N -s 10m
smf_logs -C 8 -s 1m /var/svc/log/*.log
#
# The entry below is used by turnacct(1M)
#
/var/adm/pacct -C 0 -N -a '/usr/lib/acct/accton pacct' -g adm -m 664 -o adm -p never
#
# The entry below manages the Dynamic Resource Pools daemon (poold(1M)) logfile.
#
/var/log/pool/poold -N -a 'pkill -HUP poold; true' -s 512k
~


All times are GMT -5. The time now is 09:08 PM.