一、写备份并清除老日志shell脚本:
#定义环境变量
eos_home=/home/eos
sas_home=/home/eos/sas
# 测试主辅结点
if test -d '/home/eos/sas/sas1_web1'
then
sas_log_home=$sas_home/sas1_web1/sas_domain/bin
else
sas_log_home=$sas_home/sas2_web1/sas_domain/bin
fi
# 定义并创建日志备份目录
sas_log_bak_home=$eos_home/saslog/
mkdir -p $sas_log_bak_home
# 切换目录为eos日志文件目录
cd $sas_log_home
# 获取当前系统日期
today=`date +%y%m%d`
# 备份当前日志
cp nohup.out $sas_log_bak_home/$today.log
# 清除当前日志
touch nohup.null
cp nohup.null nohup.out -f
rm nohup.null
# 清除七天前的日志
for rmfile in `find $sas_log_bak_home -ctime +7 `;
do /bin/rm -rf $rmfile;
done
清除日志(log)的shell脚本
如对本文有疑问, 点击进行留言回复!!
No.175-HackTheBox-Linux-Wall-Walkthrough渗透学习
网友评论