How long does it take for tidb_log_file_max_days to take effect after modification?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb_log_file_max_days 修改后 多久可以生效?

| username: 逍遥_猫

Experts, how long does it take for tidb_log_file_max_days to take effect after modification?
In the current session, set tidb_log_file_max_days = 10;
Waited for 5 minutes, but the TiDB logs from 10 days ago still exist.

| username: 啦啦啦啦啦 | Original post link

It is only effective for the current TiDB server. Did you use load balancing to connect and make the changes?

| username: xfworld | Original post link

Modify the configuration file. If there are several TiDB instances, just overwrite them together. It will take effect after restarting.

| username: 啦啦啦啦啦 | Original post link

Try setting set global tidb_log_file_max_days = 10;.

| username: 逍遥_猫 | Original post link

Is there an error in the official documentation? Adding global is not allowed. After modification, the value has changed, but the logs have not been deleted.

| username: 啦啦啦啦啦 | Original post link

It should have been changed to global in the later versions. I can use 6.5.

| username: 逍遥_猫 | Original post link

The current situation does not allow reload… Temporary modifications are also not effective.

| username: 逍遥_猫 | Original post link

Modified directly using the MySQL client to connect to TiDB.

| username: WalterWj | Original post link

Manually configure the variable on each node, then reload with --skip to refresh the configuration without restarting.

| username: buptzhoutian | Original post link

I couldn’t find how long it takes to take effect in the documentation.
After you made the changes, how long did it take for the logs on the corresponding tidb-server to start being automatically cleaned?

| username: tracy0984 | Original post link

In my tests with version 6.5, after modifying set tidb_log_file_max_days = 30;, it took effect immediately on the current TiDB node, and the logs were cleaned up immediately.

| username: 我是咖啡哥 | Original post link

This variable cannot be set to global. It is only effective for the current connection’s TiDB node. Tested on V6.1.0.


After execution, the logs of the node were immediately cleared.

| username: xingzhenxiang | Original post link

I directly used a script to delete it:
/usr/bin/find /tidb-deploy/tidb-3306/log/ -mtime +7 -name “tidb202log” -exec rm -rf {} ;

| username: Kongdom | Original post link

I’ve gained another little trick again~