当前位置:网站首页>一些小小小小记录~
一些小小小小记录~
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
边栏推荐
- On the problem of cliff growth of loss function in the process of training
- Visio画拓扑图随记
- Thread group ThreadGroup uses introduction + custom thread factory class to implement threadfactory interface
- yml引用其他变量
- 教育行业云迁移最佳实践:海云捷迅使用HyperMotion云迁移产品为北京某大学实施渐进式迁移,成功率100%
- JDBC和servlet写CRUD的接口总结
- 文字组合,不重复,做搜索或查询关键字匹配
- Mysql的安装过程(已经安装成功的步骤说明)
- mysql 5.1升级到5.66
- 翻牌效果
猜你喜欢
回顾2021:如何帮助客户扫清上云最后一公里的障碍?
krpano全景之vtour文件夹和tour
VMware 15pro mounts the hard disk of the real computer in the deepin system
正则表达式
RecyclerView进阶使用-实现仿支付宝菜单编辑页面拖拽功能
Storage path of mod subscribed by starbound Creative Workshop at Star boundary
redis数据库讲解二(redis高可用、持久化、性能管理)
MySQL数据库讲解(七)
RecyclerView高级使用(一)-侧滑删除的简单实现
How QT designer adds resource files
随机推荐
获取线程返回值Future接口与FutureTask类使用介绍
VMware Workstation 无法连接到虚拟机。系统找不到指定的文件
RecyclerView高级使用(二)-垂直拖拽排序的简单实现
mysql 5.1升级到5.69
VMWare安装64位XP中文教程
GFS分布式文件系统(理论)
多云数据流转?云上容灾?年前最后的价值内容分享
什么是云迁移?云迁移的四种模式分别是?
Multiple inheritance virtual base exercises
HyperMotion云迁移助力中国联通,青云完成某央企上云项目,加速该集团核心业务系统上云进程
About the configuration and use of json5 in nodejs
Jmeter设置环境变量支持在任意终端目录输入jmeter直接启动
logback-logger和root
微信小程序客服接入,实现发送和接收消息
Homebrew是什么?以及使用
政务云迁移实践 北明数科使用HyperMotion云迁移产品为某政府单位实施上云迁移项目,15天内完成近百套主机迁移
pthread_ Why does self() repeat
百度笔试2022.4.12+编程题目:简单整数问题
postman批量生产body信息(实现批量修改数据)
sql中出现一个变态问题