当前位置:网站首页>一些小小小小记录~
一些小小小小记录~
2022-04-23 14:10:00 【小灰墩墩】
一些小记录
1 日志内容定期清理
# mkdir Test
# cd Test/
# touch a{1..10}.log
# ls
a10.log a1.log a2.log a3.log a4.log a5.log a6.log a7.log a8.log a9.log
# for i in `ls ~/Test`;do echo "${i}">$i;done
以上为环境,在这个类似的环境下,配合任务计划清空*.log日志
# find /root/Test/ -name *.log |awk '{print "echo >" $1}' |bash
2 日志备份并清理超过7天的日志
#!/bin/bash
# 此脚本用于定时任务执行
# crontab -l
# 59 23 * * * /bin/bash /kingdee/nginxLog/logrotate_nginx_log.sh > /dev/null 2>&1
nginx_log_path="/kingdee/nginxLog"
function logrotate_nginx_log(){
if [ -d "${nginx_log_path}" ]; then
cd ${nginx_log_path}
cp error.log cutlog/error-$(date -d "today" +"%Y%m%d").log
echo > error.log
cp access.log cutlog/access-$(date -d "today" +"%Y%m%d").log
echo > access.log
find ${nginx_log_path}/cutlog -mtime +7 -type f -name "*.log" -exec rm -f {
} \;
fi
}
logrotate_nginx_log
3 显示磁盘超过80%的使用率及对应目录
# df -h|awk '{if(NR != 1){split($5,a,"%");if(a[1]>0){print $5,$6}}}'|sort -t '%' -k1 -nr|egrep '[8-9][0-9]%|100%'
4 top中cpu使用率(100-id)
# top -b -n1 |fgrep 'Cpu(s):' |awk -F'id,' '{split($1,k,",");v=k[length(k)];sub(/%/,"",v);printf "%s\n",100-v;}'
版权声明
本文为[小灰墩墩]所创,转载请带上原文链接,感谢
https://blog.csdn.net/swyer_66/article/details/123114337
边栏推荐
猜你喜欢
Jira截取全图
Operation instructions of star boundary text automatic translator
星界边境Starbound创意工坊订阅的mod的存放路径
A table splitting implementation scheme of MySQL and InnoDB, MyISAM and MRG_ Introduction to MyISAM and other engine application scenarios
OpenStack命令操作
Postman的安装使用及填坑心得
Gartner预测云迁移规模大幅增长;云迁移的优势是什么?
How QT designer adds resource files
win10自带Groove音乐不能播放CUE和APE文件的一种曲线救国办法,自己创建aimppack插件包,AIMP安装DSP插件
RecyclerView高级使用(一)-侧滑删除的简单实现
随机推荐
数据库DbVisualizer Pro报文件错误,导致数据连接失败
VMware Workstation 无法连接到虚拟机。系统找不到指定的文件
正则表达式
dp-[NOIP2000]方格取数
ActiveMQ Basics
HyperMotion云迁移助力中国联通,青云完成某央企上云项目,加速该集团核心业务系统上云进程
win10自带Groove音乐不能播放CUE和APE文件的一种曲线救国办法,自己创建aimppack插件包,AIMP安装DSP插件
How does void * exist?
yml引用其他变量
Five ways of using synchronized to remove clouds and fog are introduced
微信小程序客服接入,实现发送和接收消息
网页自适应,等比缩放
Date的after时间判断
JDBC详解
js 抛物线运动方法封装
sql中出现一个变态问题
文字组合,不重复,做搜索或查询关键字匹配
Wechat applet communicates with low-power Bluetooth - sending data to hardware (III)
线程间控制之CountDownLatch和CyclicBarrier使用介绍
剑指offer刷题(2)--面向华为