当前位置:网站首页>Some little records~
Some little records~
2022-04-23 14:22:00 【Small ash pier】
Some little records
1 The log content is cleaned regularly
# 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
The above is the environment , In this similar environment , Cooperate with the task plan *.log journal
# find /root/Test/ -name *.log |awk '{print "echo >" $1}' |bash
2 Log backup and cleanup 7 Day's diary
#!/bin/bash
# This script is used to schedule task execution
# 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 Display disk exceeds 80% Usage rate and corresponding directory
# 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 in cpu Usage rate (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;}'
版权声明
本文为[Small ash pier]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231409158352.html
边栏推荐
猜你喜欢
555定时器+74系列芯片搭建八路抢答器,30s倒计时,附Proteus仿真等
查找水仙花数-for循环实践
一篇博客让你学会在vscode上编写markdown
After entering the new company, the operation and maintenance engineer can understand the deployment of the system from the following items
统信UOS PHP7.2.3升级至PHP7.2.24
API gateway / API gateway (IV) - use of Kong - Integrated JWT and fuse plug-in
顺序表的操作,你真的学会了吗?
常见存储类型和FTP主被动模式解析
1分钟看懂执行流程,永久掌握for循环(附for循环案例)
xx项目架构随记
随机推荐
TLS/SSL 协议详解 (28) TLS 1.0、TLS 1.1、TLS 1.2之间的区别
SSH 通过跳板机连接远程主机
grep无法重定向到文件的问题
Qt界面优化:鼠标双击特效
51单片机的直流电机PWM调速控制系统(附Proteus仿真+C程序等全套资料)
TLS/SSL 协议详解 (30) SSL中的RSA、DHE、ECDHE、ECDH流程与区别
setcontext getcontext makecontext swapcontext
错误:无法远程查找到密钥 “428F7ECC7117F726“
Mysql的安装过程(已经安装成功的步骤说明)
Gif to still image processing
json date时间日期格式化
查找水仙花数-for循环实践
进入新公司,运维工程师从下面这几项了解系统的部署
Introduction to the use of semaphore for inter thread control
解决ssh配置文件优化以及连接慢的问题
快速搞懂线程实现的三种方式
线程间控制之CountDownLatch和CyclicBarrier使用介绍
TUN 设备原理
分分钟掌握---三目运算符(三元运算符)
ThreadGroup ThreadGroup implémente l'interface threadfactory en utilisant la classe Introduction + Custom thread Factory