Bug 9673 - max log size doesn't rotate all logs when using variable logfile names
Summary: max log size doesn't rotate all logs when using variable logfile names
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Other (show other bugs)
Version: 4.1.7
Hardware: x64 Linux
: P5 minor (vote)
Target Milestone: ---
Assignee: Andrew Bartlett
QA Contact: Samba QA Contact
: 14123 (view as bug list)
Depends on:
Reported: 2013-02-22 16:36 UTC by Marc Muehlfeld
Modified: 2020-05-25 08:58 UTC (History)
6 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Marc Muehlfeld 2013-02-22 16:36:18 UTC
I use the following parameters for logging:

log file = /var/log/samba/%m.log
debug pid = yes
log level = 1
max log size = 1000

All logfiles are rotated if they get bigger than the configured size (that's how it should be):

# ls -lh*
-rw-r--r-- 1 root root  12K 22. Feb 16:57
-rw-r--r-- 1 root root   1M 21. Feb 11:43

only the %m.log, is growing without end:

# ls -lh %m.log 
-rw-r--r-- 1 root root 20M 22. Feb 17:35 %m.log
Comment 1 Marc Muehlfeld 2014-03-21 13:53:22 UTC
My answer to Björns posting on the samba-technical mailinglist:

Am 21.03.2014 12:21, schrieb Bjoern Baumbach:
> I tried to reproduce the problem which is described in bug 9673, since
> it may be related to bug 10239. I've setup a very simple Samba v4-0-test
> server, started the nmbd and smbd and verified that the log files
> rotating as soon the max log size has been reached.
> This is my config:
> ./bin/testparm  -s
> Load smb config files from /s4/logSizetest/etc/smb.conf
> Loaded services file OK.
> Server role: ROLE_STANDALONE
> [global]
>          log file = /s4/logSizetest/var/rotateme-please-%m.log
>          max log size = 512
> Any suggestion why my setup rotates the logs and other do not?

The difference I see is, that yours is a standalone and on all machines 
I have this, are DCs.

Also on DCs, the logs of the clients are rotated. But there's also one 
logfile named "%m.log" (with your config, It would be called 
"rotateme-please-%m.log"). This one contains output from the samba 
process and not from smbd or the child-smbds forked by connecting 
clients, I think. And this one isn't rotated
Comment 2 Marc Muehlfeld 2014-05-14 07:41:09 UTC
Problem still exists in 4.1.7.
Setting product / version of this bug report to 4.1.7.
Comment 3 Marc Muehlfeld 2016-08-26 02:02:32 UTC
Update: In 4.5.0rc2, the rotation for the log file named %m.log still does not work.
Comment 4 Marc Muehlfeld 2017-02-26 14:10:58 UTC
Problem still exists in 4.6.0rc3.
Comment 5 Amit Kumar 2019-05-02 07:33:27 UTC
(In reply to Marc Muehlfeld from comment #4)
Have you tried 'samba-4.8.11'
I cannot find problem in this version. 
My smb.conf
    workgroup = WORKGROUP
    security = user
    passdb backend = tdbsam
    log level = 9
    log file = /var/log/samba/%m.log
    debug pid = yes
    max log size = 100
    path = /share

On connecting to share it rotates:
# ls -ltr
total 352
-rw-r--r--. 1 root root      0 May  2 12:53 log.smbd
drwx------. 3 root root   4096 May  2 12:53 cores
-rw-r--r--. 1 root root  92907 May  2 12:55 smbd.log
-rw-r--r--. 1 root root  95196 May  2 12:55
-rw-r--r--. 1 root root 115501 May  2 12:55 client.log.old <<<<<<<rotated
-rw-r--r--. 1 root root  44819 May  2 13:00 client.log
Comment 6 Björn Baumbach 2019-09-12 11:33:13 UTC
*** Bug 14123 has been marked as a duplicate of this bug. ***
Comment 7 Björn Baumbach 2019-09-12 11:46:52 UTC

Adam Xu opened a new bug 14123 which describes the same issue which we have here.

If you are running Samba as an AD DC, the 'log file = /var/log/samba/%m.log' will lead the samba process to write into '/var/log/samba/%m.log' without replacing the substitution, while this works for the smbd processes.

That the log rotation does not work for the samba (AD) process is a general issue, which is not related to the variable log file names.

This issue exists since a long time. As a workaround you can use the logrotate service. If you move the log file and send a SIGHUP to *all* running samba processes, samba will reopen the log file with the original name and writes the log data into this new file.

Best regards,