1.找出所有shell 里面,
找到所有shell
find /opt/task/ | grep -v pyspark2 | grep ".sh$" > a.sh
2.找出含有cluster 字符串的文件
过滤其中有submit 和 cluster 字符串的shell文件:
import os
with open("a.sh","r") as f:
for line in f.readlines():
#print line
os.system("awk 'BEGIN{flag =0 ;spark=0}{ if($0 ~ \"submit\") spark =1; if ( $0 ~ \"cluster\") flag =1; }END{ if (spark==1 && flag ==0 ) print FILENAME;}' %s "%(line))
3. 从日志中过滤出exception部分的日志。过滤出含有exception的上下10行。
grep -C 10 exception *.log