You might have noticed in the past that the default behavior in SQL Server on Linux is to keep 128 error logs in the LOG folder.
This differs from the behavior on Windows where we keep only 6 old error log files when you cycle them.
Now you have a mechanism to control how many error log files you want to retain in the LOG folder on Linux. You can install SQL Server 2019 and then use the list option of mssql-conf configuration utility, you will notice that we have a new option named errorlog.numerrorlogs.
sudo /opt/mssql/bin/mssql-conf list | grep log
If you want to retain 6 error logs in the LOG folder, you will configure it as follows:
sudo /opt/mssql/bin/mssql-conf set errorlog.numerrorlogs 6
You can verify this from the configuration settings file:
sudo cat /var/opt/mssql/mssql.conf
If you attempt to configure an invalid value, you will encounter the following error:
sudo /opt/mssql/bin/mssql-conf set errorlog.numerrorlogs 5
Now you will notice that SQL Server cycles only the error logs up to errorlog.6:
sudo ls -lt /var/opt/mssql/log/ | grep errorlog
After you implement this configuration change, you have to manually get rid of the additional error log files that existed before this configuration change went into effect. In the above example, those would be errorlog.7 onwards that needs to be manually cleaned.
If you need to reset the configuration to the defaults, you can use the following procedure:
sudo /opt/mssql/bin/mssql-conf unset errorlog.numerrorlogs
sudo cat /var/opt/mssql/mssql.conf
sudo systemctl restart mssql-server.service
If you want to test all this on your dev or QA server where there is no production workload running, you can use a script like this:
#!/bin/bash
# loop to restart sql server service
counter=1
while [ $counter -le 10 ]
do
echo $counter
sudo systemctl restart mssql-server
sleep 120
((counter++))
done
echo End of loop
Save this snippet as a bash script file and execute it.
Hope this information is useful for you!
Thanks
Suresh Kandoth
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.