技术杂记

阅读更多

统计redis连接数

echo 'client list' | /apps/svr/redis/bin/redis-cli -h 127.0.0.1 -p 6379 |awk '{print $1}' | awk -F '[=,:]' '{print $2}' | sort -n | uniq -c |sort -nr

 

 nginx日志分割脚本

#!/bin/bash
# This script run at 00:00

# The Nginx logs path
logs_path="/usr/local/nginx/logs/"
cd $logs_path

for logfile in `ls *.log`
do
mv  ${logs_path}${logfile}  ${logs_path}$(date -d "yesterday" +"%Y%m%d_")${logfile}
done

kill -USR1 `cat /usr/local/nginx/nginx.pid`

tar czvf $(date -d "yesterday" +"%Y%m%d")_log.tar.gz  $(date -d "yesterday" +"%Y%m%d_")*.log # 打包压缩日志
rm -f $(date -d "yesterday" +"%Y%m%d_")*.log # 删除压缩源文件

 

开启mysql general log

show global variables like "%genera%";
set global general_log=on;

 

mysql客户端常用命令

记录操作日志 \T \T /tmp/sql.log

\s  查看当前连接的状态信息

 

你可能感兴趣的:(技术杂记)