编写Linux脚本
下面是重新启动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脚本的更多相关文章
- Linux 脚本编写基础
txt去重 http://man.linuxde.net/sort Linux 脚本编写基础 http://www.cnblogs.com/linn/archive/2007/03/05/664 ...
- linux 使用文本编辑器编写shell脚本执行权限不够
在linux下,自己编写的脚本需要执行的时候,需要加上执行的权限 解决方式:chmod 777 test.sh
- linux 脚本编写基础(一)
1. Linux 脚本编写基础 1.1 语法基本介绍 1.1.1 开头 程序必须以下面的行开始(必须方在文件的第一行): #!/bin/sh 符号#!用来告诉系统它后面的参数是用来执行该文件的程序.在 ...
- linux 的基本操作(编写shell 脚本)
终于到shell 脚本这章了,在以前笔者卖了好多关子说shell脚本怎么怎么重要,确实shell脚本在linux系统管理员的运维工作中非常非常重要.下面笔者就带你正式进入shell脚本的世界吧. 到现 ...
- Linux安装配置maven以及搭建nexus私服(编写启动脚本)
2011年07月12日16:32 下面介绍在Linux操作系统下安装配置maven和搭建nexus私服. 一.安装前的准备 下载 jdk http://www.oracle.com/technetw ...
- 学习 Linux,101: 自定义或编写简单脚本【转】
转自:http://www.ibm.com/developerworks/cn/linux/l-lpic1-105-2/index.html 学习如何使用标准的 shell 语法.循环和控制结构,以及 ...
- 【Linux】windows下编写的脚本文件,放到Linux中无法识别格式
注意:我启动的时候遇到脚本错误 » sh startup.sh -m standalone tanghuang@bogon : command not found : command not foun ...
- Linux学习Day6:编写Shell脚本
Shell脚本命令的工作方式有两种: 交互式(Interactive):用户每输入一条命令就立即执行. 批处理(Batch):由用户事先编写好一个完整的Shell脚本,Shell会一次性执行脚本中诸多 ...
- linux环境下编写shell脚本实现启动停止tomcat服务
第一步:以管理员的身份进入控制台,在指定目录下新建一个shell脚本,我这里命名为tomcat.sh 第二步:编写shell脚本 #!/bin/bash tomcat_home=/usr/tomcat ...
随机推荐
- 【代码笔记】iOS-MBProgressHUDDemo
一,工程图. 二,代码. RootViewController.h #import <UIKit/UIKit.h> //加入头文件 #import "MBProgressHUD. ...
- Django中Ajax提交数据的CSRF问题
错误信息: Forbidden (CSRF token missing or incorrect.): 什么是CSRF: django为用户实现防止跨站请求伪造的功能,通过中间件 django.mid ...
- framework7中a标签没反应
试试在a标签上加这个样式: class="external"
- Prometheus Node_exporter 之 Node Exporter
Node Exporter 1. Node Exporter Scrape Time type: GraphUnit: secondsLabel: Seconds{{collector}} - 各个收 ...
- Oracle EBS 贷项通知单核销
SELECT cm.trx_number ,fnd_flex_ext.get_segs('SQLGL', 'GL#', gcc.chart_of_accounts_id, ad.code_combin ...
- HTML table固定表头
最近尝试了几种HTML的table固定表头的方法..额...各有利弊,但很尴尬..... 1.thead和tbody的display设置为block; 这种可以实现,但是需要提前设置好每个th和td的 ...
- 向kindle传送文件
自从有了kindle以后,只要不是pdf的电子书,基本上都用kindle来看了,毕竟水墨屏还是很护眼的,但是这就带来了向kindle传输文件的问题 绝大部分的电子书用邮件推送就可以解决了,但是还有一些 ...
- Coursera-AndrewNg(吴恩达)机器学习笔记——第四周
神经网络 1.神经网络发展的动力:在逻辑回归解决复杂的分类问题时,我们使用属性的一些组合来构造新的属性(x12,x1x2,x22...),这样就会造成属性的数目n过多,带来了大量的运算,甚至造成过拟合 ...
- gnome美化
调整工具更新可以移动窗口控件gnome-tweak-tool # dnf install gnome-tweak-tool 命令行启动,并且要在普通用户下启动 $ gnome-tweak-tool 在 ...
- November 07th, 2017 Week 45th Tuesday
Love is composed of a single soul inhabiting two bodies. 爱就是一个灵魂栖息在两个身体里. Love and family and childr ...