shell打包上个月的日志文件
来源:互联网 发布:db2 查看数据库版本 编辑:程序博客网 时间:2024/05/18 06:52
#!/bin/sh
yy=`date +%Y`
mm=`date +%m`
dd=`date +%d`
#echo $yy-$mm-$dd
if [ $mm -eq '01' ] ; then
taryear=`expr $yy - 1`;
tarmm=12;
else
taryear=$yy;
tarmm=`expr $mm - 1`;
fi
if [ $tarmm -lt 10 ] ; then
tarmm=0$tarmm
fi
#echo $taryear-$tarmm
filepath="/var/shell/logs"
tar -zcvf $filepath/test.$taryear-$tarmm.tar.gz $filepath/test.$taryear-$tarmm-*.log
#rm $filepath/test.$taryear-$tarmm-*.log
#########delete 6 month ago
if [ $mm -lt '07' ] ; then
delyear=`expr $yy - 1`;
delmm=`expr $mm + 6`;
else
delyear=$yy;
delmm=`expr $mm - 6`;
fi
if [ $delmm -lt 10 ] ; then
delmm=0$delmm
fi
rm $filepath/test.$delyear-$delmm.tar.gz
yy=`date +%Y`
mm=`date +%m`
dd=`date +%d`
#echo $yy-$mm-$dd
if [ $mm -eq '01' ] ; then
taryear=`expr $yy - 1`;
tarmm=12;
else
taryear=$yy;
tarmm=`expr $mm - 1`;
fi
if [ $tarmm -lt 10 ] ; then
tarmm=0$tarmm
fi
#echo $taryear-$tarmm
filepath="/var/shell/logs"
tar -zcvf $filepath/test.$taryear-$tarmm.tar.gz $filepath/test.$taryear-$tarmm-*.log
#rm $filepath/test.$taryear-$tarmm-*.log
#########delete 6 month ago
if [ $mm -lt '07' ] ; then
delyear=`expr $yy - 1`;
delmm=`expr $mm + 6`;
else
delyear=$yy;
delmm=`expr $mm - 6`;
fi
if [ $delmm -lt 10 ] ; then
delmm=0$delmm
fi
rm $filepath/test.$delyear-$delmm.tar.gz
可通过crontab每月定时执行。
- shell打包上个月的日志文件
- 备份上个月的日志
- shell获取上个月的最后一天
- shell 取得上个月的开始结束日期
- 删除日志文件的shell
- 在shell脚本中获取上个月最后一天的日期
- 批处理备份压缩上个月的文件及延时的方法
- shell 脚本实现文件打包
- shell脚本实现关于可执行exec文件的自动打包
- 上个月的我。
- 查找上个月的数据
- 枚举上个月的日期
- 获取上个月的日期
- 监控最新的日志文件的shell脚本
- Linux下定时切割Nginx访问日志并打包压缩的Shell脚本
- shell 统计出上个月中旬到本月中旬的所有工作日
- shell split分析日志文件
- shell 脚本完成对日志文件的提取
- linux下configure参数简单说明
- (JAVA自学笔记)I/O流操作
- Linux 系统查找文件命令总结
- mongodb的mapreduce
- 异常的总结
- shell打包上个月的日志文件
- 依赖倒置原则
- android压缩图片的方法
- 细说c语言的优先级
- NDK中调用已有的so生成新的so
- 页面中滚动条属性
- 多浏览器兼容的js获取浏览器高度和宽度方法
- nagios客户端程序的安装(翻译官方文档 NRPE.pdf)
- glibc 安装教程【亲测好用】