back.sh:
#!/bin/sh
d=$(date +%Y/%m/%d)
t=$(date +%Y%m%d%H%M)
mkdir -p /usr/local/logbak/$d
cp /var/log/natlog/nat.log /usr/local/logbak/$d/$t.log
rm -f /var/log/natlog/nat.log
如果不要清除旧log,最后一行去掉。
将脚本放在crontab中(假设脚本在/root/目录下)
0 0 * * * * /root/back.sh
50 11 * * * * /root/back.sh
50 16 * * * * /root/back.sh
If you have any questions or ideas ,please feel free to contact me : )
thx.^^
QQ: 1623213673