Re: [Samba] Log rotation issue
- Date: Sun, 3 Dec 2017 20:48:40 +0530
- From: Anantha Raghava via samba <samba@xxxxxxxxxxxxxxx>
- Subject: Re: [Samba] Log rotation issue
I am now experimenting with my test setup on the log rotation part.
While testing different scripts, I observed a very peculiar behavior
with log writing process.
If the log file name has a variable to be substituted, say %T, it
continues to write into it without creating .old file. If it is a simple
name like samba.log or dc1.current.log etc., after about 10 MB, the log
rotates,with or without my script and appends .old to actual log file
and continues to write into .old file. Could you please provide pointers
where to look for this log writing routine and why this peculiar
behavior? My smb.conf and the script I am using is shown below.
Samba version is 4.7.1
# Global parameters
netbios name = DC1
realm = EXZA.COM
server services = s3fs, rpc, nbt, wrepl, ldap, cldap, kdc,
drepl, winbindd, ntp_signd, kcc, dnsupdate
workgroup = EXZA
server role = active directory domain controller
ldap server require strong auth = No
log level = 10
log file = /var/log/samba/dc1.current.log
#"With this file name, the log gets rotated when it reaches 10
MB or above in size, One cannot exactly say at what size it rotates. The
process appends .old to the file name and continues to
write into .old file."
path = /usr/local/samba/var/locks/sysvol/exza.com/scripts
read only = No
path = /usr/local/samba/var/locks/sysvol
read only = No/*
/*Script used to rotate log*/
File size is set to 10 MB in this script. This script runs in background
(not as a cron).
file_size=`du -b /var/log/samba/dc1.current.log | tr -s '\t' ' ' |
cut -d' ' -f1`
if [ $file_size -gt $MaxFileSize ];then
cp -pr "/var/log/samba/dc1.current.log"
echo > /var/log/samba/dc1.current.log
Thanks & Regards,
Do not print this e-mail unless required. Save Paper & trees.
On 02/12/17 12:07 PM, Andrew Bartlett wrote:
On Sat, 2017-12-02 at 11:58 +0530, Anantha Raghava wrote:
Thanks for proper explanation.
To overcome this, also as we need to store logs for long, now we
have written a shell script, executed as a crop every three minutes
that checks the file size. If the file size is 1 GB or above, it
moves the log file to <logfile>.timestamp.log.old and clears the main
We have commented out the max log size in sub.conf.
If need be I can share the script here
I'm not sure that will help, that is pretty much what was happening
before. The key is to send a -HUP to the whole process tree to make
them re-open the logs, otherwise the other child samba processes will
still just write to the .old
I know this sucks. I think the solution is to have a new reopen-logs
message created so this can be used in logroate, and to have it used
internally as I mentioned.
To unsubscribe from this list go to the following URL and read the