下面是重新启动Linux下某进程的shell脚本。以tomcat进程为例:

#!/bin/sh
pid=`ps -ef|grep tomcat|grep -v grep|awk '{print $2}'`
if [ "$pid" = "" ] ; then
echo "tomcat service does not start!"
else
kill -9 $pid
pid1=`ps -ef|grep tomcat|grep -v grep|awk '{print $2}'`
if [ "$pid1" = "" ] ; then
echo "Successfully kill tomcat processes: " $pid
else
echo "tomcat kill process failed!"
exit 1
fi
fi
rm -rf /opt/tomcat/work/*
./startup.sh
pid2=`ps -ef|grep tomcat|grep -v grep|awk '{print $2}'`
if [ "$pid2" = "" ] ; then
echo "tomcat service failed to start!"
else
echo "tomcat service starts successfully:" $pid2
fi

编写Linux脚本的更多相关文章

  1. Linux 脚本编写基础

    txt去重    http://man.linuxde.net/sort Linux 脚本编写基础 http://www.cnblogs.com/linn/archive/2007/03/05/664 ...

  2. linux 使用文本编辑器编写shell脚本执行权限不够

    在linux下,自己编写的脚本需要执行的时候,需要加上执行的权限 解决方式:chmod 777 test.sh

  3. linux 脚本编写基础(一)

    1. Linux 脚本编写基础 1.1 语法基本介绍 1.1.1 开头 程序必须以下面的行开始(必须方在文件的第一行): #!/bin/sh 符号#!用来告诉系统它后面的参数是用来执行该文件的程序.在 ...

  4. linux 的基本操作(编写shell 脚本)

    终于到shell 脚本这章了,在以前笔者卖了好多关子说shell脚本怎么怎么重要,确实shell脚本在linux系统管理员的运维工作中非常非常重要.下面笔者就带你正式进入shell脚本的世界吧. 到现 ...

  5. Linux安装配置maven以及搭建nexus私服(编写启动脚本)

    2011年07月12日16:32  下面介绍在Linux操作系统下安装配置maven和搭建nexus私服. 一.安装前的准备 下载 jdk http://www.oracle.com/technetw ...

  6. 学习 Linux,101: 自定义或编写简单脚本【转】

    转自:http://www.ibm.com/developerworks/cn/linux/l-lpic1-105-2/index.html 学习如何使用标准的 shell 语法.循环和控制结构,以及 ...

  7. 【Linux】windows下编写的脚本文件,放到Linux中无法识别格式

    注意:我启动的时候遇到脚本错误 » sh startup.sh -m standalone tanghuang@bogon : command not found : command not foun ...

  8. Linux学习Day6:编写Shell脚本

    Shell脚本命令的工作方式有两种: 交互式(Interactive):用户每输入一条命令就立即执行. 批处理(Batch):由用户事先编写好一个完整的Shell脚本,Shell会一次性执行脚本中诸多 ...

  9. linux环境下编写shell脚本实现启动停止tomcat服务

    第一步:以管理员的身份进入控制台,在指定目录下新建一个shell脚本,我这里命名为tomcat.sh 第二步:编写shell脚本 #!/bin/bash tomcat_home=/usr/tomcat ...

随机推荐

  1. BZOJ5289: [Hnoi2018]排列

    传送门 第一步转化,令 \(q[p[i]]=i\),那么题目变成: 有一些 \(q[a[i]]<q[i]\) 的限制,\(q\) 必须为排列,求 \(max(\sum_{i=1}^{n}w[i] ...

  2. nginx禁止ip默认参数是$remote_addr无法禁止真实ip的问题

    由于网站使用了cdn所以$remote_addr获取的ip是cdn的ip,我现在先禁止某些ip访问发现无法禁止cdn传递过来的客户端的ip也就是$http_x_forwarded_for这个参数.比如 ...

  3. SAP FI/CO 基本概念

    每一个SAP从业者都对这些概念不陌生,理解透了这些概念,对SAP的业务体系构架才能有明确地认识. 1.集团(client)的概念:是SAP中的最高等级:每一个集团建立主数据库. 2.公司(Compan ...

  4. IDEA报错:Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. ('crmWatcherService'错误)

    单表插入项目,插入前正常,插入后运行webapplication报错: run: debug: 于webapplication报错: Injection of autowired dependenci ...

  5. 8.2、常用模块介绍2:xml,configparser,hashlib

    xml: 介绍:包含关于可扩展标记语言xml的函数 使用: python有三种方法解析XML--SAX,DOM,以及ElementTree,由于xml技术落后,所以这里不对sax,dom介绍: xml ...

  6. python数据类型之间的转换

    1,字符串转整型,前提条件是该字符串为纯数字. a = '1' a = int(a) 2,整型转字符串 a= 1 a = str(a) 3,整型转浮点型 a = 1 a = float(a) 4,浮点 ...

  7. 注意Sqlserver中使用with(nolock)后实际上还是会加架构锁,只是不对要查询的数据加S锁而已(转载)

    开发人员喜欢在SQL脚本中使用WITH(NOLOCK), WITH(NOLOCK)其实是表提示(table_hint)中的一种.它等同于 READUNCOMMITTED . 具体的功能作用如下所示(摘 ...

  8. 关于<asp:checkBoxList>控件的对齐方法

    定义和用法 TextAlign 属性用于获取或设置 CheckBoxList 项目的文本的文本对齐方式. 语法 <asp:CheckBoxList TextAlign="align&q ...

  9. 阿里云centos7.2 lamp配置

    安装apache 1.安装yum -y install httpd 2.设置apache服务开机启动systemctl enable httpd.service 3.开启apache服务systemc ...

  10. Linux解压.tar .tgz .tar.gz .tar.Z等文件

    .tar 解包:tar xvf FileName.tar 打包:tar cvf FileName.tar DirName (注:tar是打包,不是压缩!) ---------------------- ...