Hello guys,
I am having hard time understanding how to use logadm to rotate logs on solaris 11. Basically I want rotate my logs as soon as my file have certain size. Let's say 1M. Here is an example :
logadm -C8 -s 1m -t logfile.log.0 -z 0 logfile.log
The main issue I am having is that when the rotation is done, rsyslog just follow the the renamed logfile.
For example, if the logfile is renamed to logfile.log.0 and new file with name logfile.log is create. rsyslog continue writing on logfile.log.0, instead of logfile.log. on the other hand, if I move logfile.log away, rsyslog just follow. If I delete the logfile.log file. rsyslog stop working until I restart it.
I dont really know what is wrong here.
Can you help please ?
my config :
#
# Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
#
# logadm.conf
#
# Default settings for system log file management.
# The -w option to logadm(8) 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 -a '/usr/sbin/svccfg -s svc:/system/system-log refresh'
/var/adm/messages -C 4 -a '/usr/sbin/svccfg -s svc:/system/system-log refresh'
/var/cron/log -c -s 512k -t /var/cron/olog
/var/fm/fmd/errlog -N -s 2m -M '/usr/sbin/fmadm -q rotate errlog && mv /var/fm/fmd/errlog.0- $nfile'
/var/fm/fmd/fltlog -N -A 6m -s 10m -M '/usr/sbin/fmadm -q rotate fltlog && mv /var/fm/fmd/fltlog.0- $nfile'
smf_logs /var/svc/log/*.log -C 8 -s 1m -c
/var/log/vntsd/*/console-log -C 6 -S 100m -s 1b -p 1m -c
#
# The entry below is used by turnacct(8)
#
#
#
#
#costum logs
/var/log/rsyslog/c1/*.log -s 10k -z 10 -a 'echo This is done >> /tmp/logadmin.txt'
/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(8)) logfile.
#
/var/log/pool/poold -N -s 512k -a 'pkill -HUP poold; true'
# DO NOT MODIFY logadm-upgrade-begin DO NOT MODIFY
# DO NOT MODIFY Added by logadm-upgrade for /etc/logadm.d/fmd.logadm.conf
/var/fm/fmd/infolog -N -A 2y -S 50m -s 10m -M '/usr/sbin/fmadm -q rotate infolog && mv /var/fm/fmd/infolog.0- $nfile'
/var/fm/fmd/infolog_hival -N -A 2y -S 50m -s 10m -M '/usr/sbin/fmadm -q rotate infolog_hival && mv /var/fm/fmd/infolog_hival.0- $nfile'
# DO NOT MODIFY Added by logadm-upgrade for /etc/logadm.d/zoneadm.logadm.conf
/var/log/zones/zoneadm.* -A 60d -p never -t $file
/var/log/zones/*.{console,messages} -C 4 -N -p 1w -m 600 \
-a 'pkill -HUP -z global -u root -x zoneadmd || true'
/var/log/zones/zone_cmd -C 4 -N -p 1w -m 600
# DO NOT MODIFY logadm-upgrade-end DO NOT MODIFY
I am on : Solaris 11.4
This is the default config but normally since I am using logadm as command line, the default config is not used.
On the official website for rsyslog(https://www.rsyslog.com/doc/master/tutorials/log_rotation_fix_size.html). I have tried exactly the same this, but seems not working.
# start log rotation via outchannel
# outchannel definition
$outchannel log_rotation,/var/log/log_rotation.log, 52428800,/var/log/rsyslog/log_rotation_script
# activate the channel and log everything to it
*.* :omfile:$log_rotation
# end log rotation via outchannel
with /var/log/rsyslog/log_rotation_script containing mv -f /var/log/log_rotation.log /var/log/log_rotation.log.1