一、批量杀死进程
ps -ef |grep mysql | awk '{print $2}' |head -1|xargs kill -9
二、Windows下GBK编码转换UTF8
iconv -f GBK -t UTF8 addreezd.csv -o addreezd2.csv
三、当Tomcat异常宕机后重启服务
#!/bin/bash Tomcatstart="/usr/install/tomcat8/bin/startup.sh" #tomcat安装位置 Time=$(date +%F) #获取当前日期 while true do jps > /tmp/ps.txt sleep 50 #暂停50s if grep "Bootstrap" /tmp/ps.txt #判断该文件中是否包含Bootstrap then echo " $Time tomcat is healthy" #包含则判断tomcat正常运行 else echo " $Time tomcat is crash..." 2>>/tmp/tomcaterror.log /bin/sh ${Tomcatstart} fi sleep 240 echo " $Time one time is ok" done
四、通过分析nginx日志分析一个网站的UV、PV等
1、使用AWK等功能 UV cat ~/output/nginx/logs/portal_ssl.access.log |awk -F" " '{ print $1 }' | sort -u |wc -l PV cat ~/output/nginx/logs/portal_ssl.access.log |awk -F" " '{ print $1 }' |wc -l 2、使用Python脚本 #/usr/bin/env python #-*-coding:UTF-8 -*- ips=[] with open("/home/admin/output/nginx/logs/portal_ssl.access.log","r") as ngfile: for line in ngfile: ips.append(line.split()[0]) print("PV is {0}".format(len(ips))) print("UV is {0}".format(len(set(ips))))
转载于:https://blog.51cto.com/dreamlinux/1852996