一、批量杀死进程
1
|
ps
-ef |
grep
mysql |
awk
'{print $2}'
|
head
-1|
xargs
kill
-9
|
二、Windows下GBK编码转换UTF8
1
|
iconv -f GBK -t UTF8 addreezd.csv -o addreezd2.csv
|
三、当Tomcat异常宕机后重启服务
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#!/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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
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))))
|
本文转自 tianya1993 51CTO博客,原文链接:http://blog.51cto.com/dreamlinux/1852996,如需转载请自行联系原作者