linux重启服务的脚本命令
最近做网站测试,每次测试完成都要重启服务,为此写了一个简单的shell脚本
linux服务重启shell脚本示例
2014年12月18日 linux服务重启脚本,如何实现linux服务的定时重启,可以借助shell脚本来完成,ps命令捕获进程信号,kill命令杀死进程,然后linux服务重新启动。 例如: #ls -l
drwxr-xr-x. richmail richmail 12月 : admin
drwxr-xr-x. richmail richmail 12月 : help
-rw-rw-r--. richmail richmail 12月 : help.zip
drwxr-xr-x. richmail richmail 12月 : mail
-rwxr-xr-x. richmail richmail 12月 : restartTomcat.sh
-rw-r--r--. richmail richmail 12月 : ThinkMail_webmail(V2.0.0)_201412101739.zip
drwxr-xr-x. richmail richmail 11月 : tomcat7
-rw-rw-r--. richmail richmail 10月 : x
[richmail@datanode1 webmailsvr]$ cat restartTomcat.sh
#Author : dengliang
#Desc : restart tomcat
#Time : --
tomcatpath="/home/richmail/web/webmailsvr/tomcat7" linux服务重启shell脚本,以tomcat服务为例: 复制代码 代码示例: #!/bin/sh
#kill tomcat pid pidlist=`ps -ef|grep $tomcatpath |grep -v "grep"|awk '{print $2}'`
if [ "$pidlist" = "" ]
then
echo "no tomcat pid alive!"
else
echo "tomcat pid list : $pidlist"
echo "killing pidlist : $pidlist"
kill - $pidlist
echo "tomcat stopped successfully!"
sleep
fi
echo "now starting tomcat......"
cd $tomcatpath/bin 调用: ./startup.sh
cd -
#!/bin/sh #kill tomcat pid pidlist=`ps -ef|grep tomcat_message_8002|grep -v "grep"|awk '{print $2}'` //找到tomcat的PID号 echo "tomcat Id list :$pidlist" //显示pid kill - $pidlist //杀掉改进程 echo "KILL $pidlist:" //提示进程以及被杀掉 echo "service stop success" echo "start tomcat" cd /home/app/tomcat_message_8002 rm -rf work/* cd bin ./startup.sh ;tail -f ../logs/catalina.out
linux重启服务的脚本命令的更多相关文章
- Linux 定时执行shell脚本命令之crontab
crontab可以在指定的时间执行一个shell脚本以及执行一系列Linux命令 例如:服务器管理员定时备份数据库数据.日志等 详解: 常用命令: crontab –e //修改 crontab 文件 ...
- linux下服务启动脚本
#!/usr/bin/env python# -*- coding: utf-8 -*-# @File : deployment.py# @Author: Anthony.waa# @Date : 2 ...
- [Python]linux自己定义Python脚本命令
在window下写好的程序配置到Linux上,要实现随意文件夹下的命令调用. 因为初学Linux,这里从文件传输等最主要的方法入手,记录配置的过程中遇到的各种问题. 连接远端server 这里使用pu ...
- Linux中执行shell脚本命令的4种方法总结
bash shell 脚本的方法有多种,现在作个小结.假设我们编写好的shell脚本的文件名为hello.sh,文件位置在/data/shell目录中并已有执行权限. 方法一:切换到shell脚本所在 ...
- Linux一些服务的启动命令
http:服务service httpd start 启动 service httpd restart 重新启动 service httpd stop 停止服务 启动ssh服务 # /etc/init ...
- linux运维中的命令梳理(四)
----------管理命令---------- ps命令:查看进程 要对系统中进程进行监测控制,查看状态,内存,CPU的使用情况,使用命令:/bin/ps (1) ps :是显示瞬间进程的状态,并不 ...
- linux定时重启tomcat服务的脚本学习
要求:在linux中定时重启一个tomcat服务 一:shell脚本即Shell Script [1],Shell脚本与Windows/Dos下的批处理相似,也就是用各类命令预先放入到一个文件中,方便 ...
- Linux下重启多个 tomcat 服务的脚本
由于修改tomcat的配置文件或手动操作数据库数据后,tomcat的缓存和redis的缓存很严重,需要经常重启tomcat来释放缓存,经常就是手动重启. # .查找tomcat的进程ID ps -ef ...
- Linux/CentOS 服务安装/卸载,开机启动chkconfig命令详解|如何让MySQL、Apache开机启动?
chkconfig chkconfig在命令行操作时会经常用到.它可以方便地设置和查询不同运行级上的系统服务.这个可要好好掌握,用熟练之后,就可以轻轻松松的管理好你的启动服务了. 注:谨记chkcon ...
随机推荐
- $Django Rest Framework-序列化组件
1 序列化组件 e=serializers.SerializerMethodField() # 方法名:叫get_字段名, 参数,返回字典 def get_e(self,obj): #obj为b ...
- django-form介绍
Django form表单 目录 普通方式手写注册功能 views.py login.html 使用form组件实现注册功能 views.py login2.html 常用字段与插件 initia ...
- O(big oh) (big omega) (big theta)
big oh big omega big theta more
- 5分钟搞定Nginx安装
1. 安装gcc(centos 7之后一般已自带,可以在第6步失败后再安装) yum install gcc gcc-c++ 2. 安装pcre yum install -y pcre pcr ...
- [C][代码实例]冒泡排序
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h& ...
- cocos2dx-lua 延迟调用函数和定时器
下面是cocos官方的方法. function performWithDelay(node, callback, delay) local delay = cc.DelayTime:create(de ...
- LINUX-redis & mongodb
ubuntu安装redis: apt-get -y install redis-serverubuntu启动redis: /etc/init.d/redis-server restart linux安 ...
- poj1562 Oil Deposits 深搜模板题
题目描述: Description The GeoSurvComp geologic survey company is responsible for detecting underground o ...
- css3 曲线阴影,翘边阴影
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Windows服务启动进程----Cjwdev.WindowsApi.dll
windows服务下无法启动外部程序 做一个windows服务监听服务,涉及到windows服务启动外部程序的一个过程,但是调试测试发现,无法简单的用process.start()这种方法, 原因是在 ...