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: