当前位置:网站首页>一些小小小小记录~
一些小小小小记录~
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
边栏推荐
猜你喜欢

ThreadGroup ThreadGroup implémente l'interface threadfactory en utilisant la classe Introduction + Custom thread Factory

xx项目架构随记

VMWare安装64位XP中文教程

困扰多年的系统调研问题有自动化采集工具了,还是开源免费的

sql中出现一个变态问题

man man随记和crontab的@reboot用法

squid代理

RecyclerView细节研究-RecyclerView点击错位问题的探讨与修复

MySQL-InnoDB-事务

金融行业云迁移实践 平安金融云整合HyperMotion云迁移解决方案,为金融行业客户提供迁移服务
随机推荐
js 递归(1)
RecyclerView细节研究-RecyclerView点击错位问题的探讨与修复
pthread_ Why does self() repeat
Installation and use of postman pit
剑指offer刷题(1)--面向华为
Understand the concepts of virtual base class, virtual function and pure virtual function (turn)
Request module
Jira截取全图
Operation instructions of star boundary automatic text translator (advanced version)
yml引用其他变量
VMware 15pro mounts the hard disk of the real computer in the deepin system
Storage path of mod subscribed by starbound Creative Workshop at Star boundary
MYSQL一种分表实现方案及InnoDB、MyISAM、MRG_MYISAM等各种引擎应用场景介绍
man man随记和crontab的@reboot用法
Wechat applet communicates with low-power Bluetooth - sending data to hardware (III)
字节面试编程题:最小的K个数
mysql 5.1升级到5.68
ActiveMQ Basics
elk安装
预览CSV文件