当前位置:网站首页>一些小小小小记录~
一些小小小小记录~
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
边栏推荐
- 金融行业云迁移实践 平安金融云整合HyperMotion云迁移解决方案,为金融行业客户提供迁移服务
- OpenStack命令操作
- std::map 和 std::vector 内存释放
- How does void * exist?
- Logging module
- redis数据库讲解二(redis高可用、持久化、性能管理)
- OpenStack如何跨版本升级
- 倒计时1天~2022云容灾产品线上发布会即将开始
- Five ways of using synchronized to remove clouds and fog are introduced
- Recyclerview advanced use (II) - simple implementation of vertical drag and drop sorting
猜你喜欢

微信小程序将原生请求通过es6的promise来进行优化

01-nio basic ByteBuffer and filechannel

在MAC上安装mysql

什么是云迁移?云迁移的四种模式分别是?

Jmeter设置环境变量支持在任意终端目录输入jmeter直接启动

回顾2021:如何帮助客户扫清上云最后一公里的障碍?

xx项目架构随记

更改plsql工具栏的图标大小

On the multi-level certificate based on OpenSSL, the issuance and management of multi-level Ca, and two-way authentication

多云数据流转?云上容灾?年前最后的价值内容分享
随机推荐
快速搞懂线程实现的三种方式
JSP学习2
困扰多年的系统调研问题有自动化采集工具了,还是开源免费的
OpenStack如何跨版本升级
MySQL数据库讲解(十)
操作系统常见面试题目:
数据库DbVisualizer Pro报文件错误,导致数据连接失败
VMware 15pro mounts the hard disk of the real computer in the deepin system
mysql查询库大小
拨开云雾synchronized使用五种方式介绍
Some good articles on pthread multithreading
处理 mkdir:无法创建目录“aaa“:只读文件系统
STD:: map and STD:: vector memory free
x509证书cer格式转pem格式
HyperMotion云迁移完成阿里云专有云产品生态集成认证
星界边境文本自动翻译机(高级版)使用说明
Algorithem_ReverseLinkedList
关于Jmeter启动闪退问题
线程间控制之Semaphore使用介绍
Operation instructions of star boundary text automatic translator