在log同目录下新建文件 move_log_files.shell
time=$(date "+%Y_%m_%d")
cd [项目路径log文件下]
for file in $(find ./* -iname "*[根据log文件名查找].log");do
newfile=${file%'.log'*}_$time
if [ ! ${newfile} ] ;then
exit 113
fi
cp ./$file ./${newfile}.log
echo '' > ./$file
done
crontab 新增
0 0 * * * /bin/sh 项目路径/move_log_files.sh
最终log文件
test.log
test_2021_11_01.log
test_2021_11_02.log