PAdajar2
asked on
AIX syslog rotation
How do you setup a syslog rotation?
Thanks!
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
/etc/syslog.pid should be reliable on AIX. The actual logic I use in my script for this looks like this, however:
#
# This sends a HUP to syslog so it will close it's file descriptors
# and help us assure we're getting all the data.
#
function restart_syslogd {
for syslog_pidfile in \
/var/run/syslog.pid \
/etc/inet/syslog.pid \
/etc/syslog/syslog.pid \
/etc/syslog.pid \
/dev/null
do if [ -r "$syslog_pidfile" ]
then debug "$0: setting syslog_pidfile to '$syslog_pidfile'"
break
fi
done
cat "$syslog_pidfile" | read pid
if [ -z "$pid" ]
then debug "$0: getting syslog pid from ps"
ps -ef | grep /syslogd | grep -v grep | read user pid junk
fi
if [ -n "$pid" ]
then verbose "restarting syslogd"
debug "syslog PID is '$pid'"
if kill -HUP "$pid"
then :
else warn "$0: can't HUP syslog process '$pid'"
fi
else warn "$0: don't know the syslog process id"
fi
}
#
# This sends a HUP to syslog so it will close it's file descriptors
# and help us assure we're getting all the data.
#
function restart_syslogd {
for syslog_pidfile in \
/var/run/syslog.pid \
/etc/inet/syslog.pid \
/etc/syslog/syslog.pid \
/etc/syslog.pid \
/dev/null
do if [ -r "$syslog_pidfile" ]
then debug "$0: setting syslog_pidfile to '$syslog_pidfile'"
break
fi
done
cat "$syslog_pidfile" | read pid
if [ -z "$pid" ]
then debug "$0: getting syslog pid from ps"
ps -ef | grep /syslogd | grep -v grep | read user pid junk
fi
if [ -n "$pid" ]
then verbose "restarting syslogd"
debug "syslog PID is '$pid'"
if kill -HUP "$pid"
then :
else warn "$0: can't HUP syslog process '$pid'"
fi
else warn "$0: don't know the syslog process id"
fi
}
ASKER
Im a rookie guys so you have to bear with me.
Where exactly do these scripts go?
Thanks
Where exactly do these scripts go?
Thanks
Doesn't matter where you place them in the filesystem. The important thing is to call them out of cron on whatever schedule you want. See the man pages for cron and crontab.
ASKER
k, now how do i customizze this for my system?
ASKER
how do you make the script delete log files that are x days old?
Thanks again
Thanks again
Hey, that's a whole other question ;-)
Anyway, see the man page for find.
Anyway, see the man page for find.
ASKER
thanks! any chance i can also squeeze out of you how you delete the previous contents of the log file as opposed to just appending to the same file?
Thanks
Thanks
> filename
will clobber the previous contents.
will clobber the previous contents.
ASKER
thanks!
this is not a reliable pid for the syslog process.
Use somthing like
ps -ef | grep \syslogd |awk 'print $1'