linux 修改句柄数 关闭缓存

更改swap echo vm.swappiness = 0 >> /etc/sysctl.conf 修改句柄数 echo “* hard nofile 65536” >> /etc/security/limits.conf ulimit -n 51200 echo “ulimit -SHn 100000” >> /etc/profile echo “* soft nofile 100000” >> /etc/security/limits.conf echo “* hard nofile 100000” >> /etc/security/limits.conf echo “* soft nproc 65535” >> /etc/security/limits.conf echo “* hard nproc 65535” >> /etc/security/limits.conf

archive_sql_log.sh

#!/bin/bash DATE=`date +’%Y-%m-%d’` cd /home/log/sql FILE=`ls –ignore=”sqltime_$DATE.log” –ignore=”sqlcount_$DATE.log” –ignore=”tar_log.sh” –ignore=”*.tar.gz”` for i in $FILE do tar -czf $i.tar.gz $i –remove-files done cd /home/log FILE=`ls *.log` for i in $FILE do tar -czf $i.tar.gz $i –remove-files done

archive_log.sh

  #!/bin/bash DATE=`date +’%Y-%m-%d’` cd /home/log/sql FILE=`ls –ignore=”sqltime_$DATE.log” –ignore=”sqlcount_$DATE.log” –ignore=”tar_log.sh” –ignore=”*.tar.gz”` for i in $FILE do ## 循环遍历静默压缩 tar -czf $i.tar.gz $i –remove-files #zip -rq $i.zip $i ## 压缩完成显示一个 #echo $i.zip done

查找文件find

查找最近8天修改过的文件 find . -type f -mtime -8 -ls find . -type f -mtime -10 -ls 根据文件名查找 find . -iname “*.txt”    

查看空间占用 du df

查看空间占用 df -h du -h  统计当前目录大小 du -sh /data 统计目录大小,以直观方式展现 du -h –max-depth=1 一级子目录 du -h  –max-depth=1|grep ‘key’ 查找key目录,并统计大小 du -h –max-depth=1 |grep [TG] 查找T or G目录,并统计大小 du -h  –max-depth=1|grep ‘key’ |sort 排序 du -h  –max-depth=1|grep ‘key’ |sort -nr倒排序

linux 查找日志

查找日志 cat 日志文件 |grep -C 行数 “搜索文本” cat access.log |grep -C1 “the userid:” cat access.log|grep -C10 “requestId:1249665” cat access.log|grep -A50 “343443” cat access_20201105.log |grep -C10 “GYL12-20201022-0001”