shell脚本对多端口进程kill并重启进程
#!/bin/bash
export LOG_FILE='/data/log/search'
spider_search_pid=`ps aux|grep flask_web_search|grep -v "grep"|awk '{print $2}'`
if [ "$spider_search_pid" ];then
ps aux|grep flask_web_search|grep -v "grep"|awk '{print $2}'|xargs kill -
echo "old spider search process is killed"
fi
cd /data/spider-search/
for port in
do
file_search='flask_web_search.py'
log_file='/data/log/web'$port'.log'
echo $port
nohup /usr/bin/python3 $file_search $port >$log_file >& &
done
sleep
spider_search_port01=` netstat -lntp|grep ""|awk '{print $4}'|awk -F":" '{print $2}'`
echo $spider_search_port01
if [ "$spider_search_port01" ];then
echo -e "\033[32m[ spider_search_port 5001 started success on prod env ! ]\033[0m"
fi
spider_search_port02=` netstat -lntp|grep ""|awk '{print $4}'|awk -F":" '{print $2}'`
echo $spider_search_port02
if [ "$spider_search_port02" ];then
echo -e "\033[32m[ spider_search_port 5555 started success on prod env ! ]\033[0m"
fi
spider_search_port03=` netstat -lntp|grep ""|awk '{print $4}'|awk -F":" '{print $2}'`
echo $spider_search_port03
if [ "$spider_search_port03" ];then
echo -e "\033[32m[ spider_search_port 5556 started success on prod env ! ]\033[0m"
fi
spider_search_port04=` netstat -lntp|grep ""|awk '{print $4}'|awk -F":" '{print $2}'`
echo $spider_search_port04
if [ "$spider_search_port04" ];then
echo -e "\033[32m[ spider_search_port 5557 started success on prod env ! ]\033[0m"
fi
exit
shell脚本对多端口进程kill并重启进程的更多相关文章
- shell脚本批量/单独启动、停止、重启java独立jar程序
本人最近半年使用阿里dubbo做开发,并在公司内部大力进行推广,将原来一个笨重且不易于维护的大项目切分成多个相对独立的java程序,好处是显而易见的,但是随着切分的独立运行程序包越来越多,程序的部署变 ...
- 【shell脚本实例】一个恶作剧—— kill掉占用CPU较高的matlab进程
我们实验室有台服务器,博士们在服务器上跑MATLAB,基本都是4核都是超过95%的CPU占用,想了个恶作剧的shell 定时kill掉MATLAB程序,是不是很邪恶啊,哈哈~~~ 不过我只是干过一次 ...
- shell脚本中根据端口号kill对应的应用进程
一.使用情景 在Jenkins的自动部署中,每次重新部署我们都需要先关闭原先的应用进程,然后重新部署启动.在使用tomcat时,我们可以通过startup.sh和shutdown.sh进行对应操作.但 ...
- shell脚本:Ctrl+C终止的是哪个进程
aa.sh中的内容如下图: 运行sh aa.sh, 显示aa.txt后面几行, 此时开启了两个进程:一个sh运行,一个tail -f运行 按Ctrl+C 会终止此sh进程, 父进程死了,里面的tail ...
- shell脚本实现批量端口扫描
#!/bin/bash # Telnet Batach readonly TMOUT= ip_prefix="192.168" ip_network_range="80- ...
- Shell脚本检测程序,如果挂了就重启程序
脚本如下: #!/bin/sh #要检查的进程名 PROGRESS_NAME="heihu_server" #----------------------------------- ...
- Shell脚本 - 用来检查memcache并自动重启生效脚本
#!/bin/sh#check memcache process and restart if downmm_bin="/usr/local/bin/memcached"mm_lo ...
- 在linux中安装jdk以及tomcat并shell脚本关闭启动的进程
在命令行模式中输入uname -a ,如下图,当界面展示i386就说明本linux系统为32版本,就在官网下载对应jdk版本,或者直接到我的网盘上下载http://pan.baidu.com/s/1c ...
- LINUX SHELL脚本攻略笔记[速查]
Linux Shell脚本攻略笔记[速查] 资源 shell script run shell script echo printf 环境变量和变量 pgrep shell数学运算 命令状态 文件描述 ...
随机推荐
- luogu P1012 拼数
题目描述 设有n个正整数(n≤20),将它们联接成一排,组成一个最大的多位整数. 例如:n=3时,3个整数13,312,343联接成的最大整数为:34331213 又如:n=4时,4个整数7,13,4 ...
- 【二分】【三分】【计算几何】XIII Open Championship of Y.Kupala Grodno SU Grodno, Saturday, April 29, 2017 Problem L. Lines and Polygon
题意:给你一个凸多边形,和多次询问,每次询问给你一条直线,问你这条直线与凸包上的顶点的最近距离是多少. 记当前询问的直线的斜率为K, 先找到与这条直线距离最远的两个点: 就把凸包所有的边当做有向直线进 ...
- 【LCA】BZOJ1832 & BZOJ1787(AHOI)-集会
[题目大意] 一个图有n个点n-1条边(也就是说是一棵树),求其中三点共同到达某一点经过总共的最少边数以及共同到达的那一点. [思路] 借用一下黄学长给的结论:三个点两两取LCA,其中必有两个相同,则 ...
- 【递推+高精度】POJ2506-Tiling
思路别人那里讲的很清楚了,我就不阐述了.链接 #include<iostream> #include<cstdio> #include<cmath> #includ ...
- c99柔性数组
变长结构体 struct test { int nSize; char data[]; // 或者 char data[0];但建议使用 char data[]; 注意:c98 时不支持柔性数组,其仅 ...
- 数组中的forEach和map的区别
大多数情况下,我们都要对数组进行遍历,然后经常用到的两个方法就是forEach和map方法. 先来说说它们的共同点 相同点 都是循环遍历数组中的每一项 forEach和map方法里每次执行匿名函数都支 ...
- Codeforces Round #343 (Div. 2) D. Babaei and Birthday Cake 线段树维护dp
D. Babaei and Birthday Cake 题目连接: http://www.codeforces.com/contest/629/problem/D Description As you ...
- Integer引用类型问题
public class TestMain { public static void main(String[] args) { Integer integer = 2; go(2); System. ...
- C# Sftp操作
SFTP释义-----引自百度百科 sftp是Secure File Transfer Protocol的缩写,安全文件传送协议.可以为传输文件提供一种安全的网络的加密方法.sftp 与 ftp 有着 ...
- Java_导出Excel
导出的Excel标题.Sheet名称.数据内容都可以使用中文 一.pom.xml引入jar包 1 2 3 4 5 <dependency> <groupId ...