log4j rename方法

log4j日志切割 os.rename

[root@zz test]# cat a2.py 
import os
os.rename('a.txt','b.txt');
[root@zz test]# cat a.txt 
111111111111111111111
222222222222222222222
[root@zz test]# ls
a1.py  a2.py  a.txt  tst.log.1  tst.log.2
[root@zz test]# python ^C
[root@zz test]# stat a.txt
  File: `a.txt'
  Size: 44            Blocks: 8          IO Block: 4096   regular file
Device: 803h/2051d    Inode: 948701      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2023-12-23 00:52:55.466002465 +0800
Modify: 2023-12-23 00:52:50.717999741 +0800
Change: 2023-12-23 00:52:50.717999741 +0800
[root@zz test]# ls
a1.py  a2.py  a.txt  tst.log.1  tst.log.2
[root@zz test]# python a2.py  a.txt 
[root@zz test]# stat b.txt 
  File: `b.txt'
  Size: 44            Blocks: 8          IO Block: 4096   regular file
Device: 803h/2051d    Inode: 948701      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2023-12-23 00:52:55.466002465 +0800
Modify: 2023-12-23 00:52:50.717999741 +0800
Change: 2023-12-23 00:53:04.811999759 +0800

[root@zz test]# ls -ltr
total 40972
-rw-r--r-- 1 root root      569 Dec 23 00:38 a1.py
-rw-r--r-- 1 root root 20971516 Dec 23 00:44 tst.log.1
-rw-r--r-- 1 root root 20971507 Dec 23 00:45 tst.log.2
-rw-r--r-- 1 root root       38 Dec 23 00:48 a2.py
-rw-r--r-- 1 root root       44 Dec 23 00:52 b.txt