CentOS6.5启停脚本例子
来源:互联网 发布:sql server删除表 编辑:程序博客网 时间:2024/05/17 04:48
#!/bin/bash# The next lines are for chkconfig on RedHat systems.# chkconfig: 35 98 02# description: Starts and stops Server# The next lines are for chkconfig on SuSE systems.# /etc/init.d/xxx#### BEGIN INIT INFO# Provides: Chinge_Yang# Required-Start: $network $syslog# Required-Stop:# Default-Start: 2 3 5# Default-Stop: 0 6# Short-Description: Starts and stops Server# Description: Starts and stops Server### END INIT INFO#获取脚本所存放目录
cd `dirname $0`
bash_path=`pwd`
#脚本名
me=$(basename $0)
#定义输出颜色函数
function red_echo () {
#用法: red_echo "内容"
local what=$*
echo -e "$(date +%F-%T) \e[1;31m ${what} \e[0m"
}
function green_echo () {
#用法: green_echo "内容"
local what=$*
echo -e "$(date +%F-%T) \e[1;32m ${what} \e[0m"
}
function yellow_echo () {
#用法: yellow_echo "内容"
local what=$*
echo -e "$(date +%F-%T) \e[1;33m ${what} \e[0m"
}
function twinkle_echo () {
#用法: twinkle_echo $(red_echo "内容") ,此处例子为红色闪烁输出
local twinkle='\e[05m'
local what="${twinkle} $*"
echo -e "$(date +%F-%T) ${what}"
}
function return_echo () {
[ $? -eq 0 ] && green_echo "$* 成功" || red_echo "$* 失败"
}
function return_error_exit () {
[ $? -eq 0 ] && local REVAL="0"
local what=$*
if [ "$REVAL" = "0" ];then
[ ! -z "$what" ] && green_echo "$what 成功"
else
red_echo "$* 失败,脚本退出"
exit 1
fi
}
#定义确认函数
function user_verify_function () {
while true;do
echo ""
read -p "是否确认?[Y/N]:" Y
case $Y in
[yY]|[yY][eE][sS])
echo -e "answer: \\033[20G [ \e[1;32m是\e[0m ] \033[0m"
break
;;
[nN]|[nN][oO])
echo -e "answer: \\033[20G [ \e[1;32m否\e[0m ] \033[0m"
exit 1
;;
*) continue ;;
esac
done
}
#定义跳过函数
function user_pass_function () {
while true;do
echo ""
read -p "是否确认?[Y/N]:" Y
case $Y in
[yY]|[yY][eE][sS])
echo -e "answer: \\033[20G [ \e[1;32m是\e[0m ] \033[0m"
break
;;
[nN]|[nN][oO])
echo -e "answer: \\033[20G [ \e[1;32m否\e[0m ] \033[0m"
return 1
;;
*) continue ;;
esac
done
}
#cd到程序目录
program_path=$(dirname $bash_path)
program_name="play"
function start () {
#cd $bash_path/../logfile/
#判断程序是否运行
program_pid=$(pidof $program_path/$program_name)
if [[ -z "$program_pid" ]];then
cd $program_path
nohup ./$program_name &
else
yellow_echo "This program $program_path/$program_name is running,no need to start"
exit 0
fi
program_pid=$(pidof $program_path/$program_name)
[[ ! -z "$program_pid" ]] && green_echo "This program start successed" || return_error_exit "This program start failed."
}
function stop(){
#判断pid存在情况
program_pid=$(pidof $program_path/$program_name)
[[ -z "$program_pid" ]] && yellow_echo "This program $program_path/$program_name is not running." || { kill -9 $program_pid && red_echo "This program $progra
m_path/$program_name be end."; }
}
function status(){
program_pid=$(pidof $program_path/$program_name)
[[ -z "$program_pid" ]] && yellow_echo "This program is not running" || green_echo "This program $program_path/$program_name is running"
}
case $1 in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
*)echo "$0 {start|stop|restart|status}"
exit 4;
;;
esac
- CentOS6.5启停脚本例子
- weblogic启停脚本
- 应用启停脚本
- Cordys服务器启停脚本
- Oracle BIEE启停脚本
- Linux 程序启停脚本
- Memcached启停脚本小结
- LNMP启停控制自动脚本
- HACMP切换启停DB2的脚本
- TimesTen Active standby切换启停脚本
- HACMP启停Oracle 两个常用脚本
- Onsql和MySQL的启停脚本
- 编写Nginx启停服务脚本
- 编写Redis启停服务脚本
- linux 重写Tomcat启停脚本
- oracle启停脚本(HA)
- MySQL起停脚本
- centos6.5网卡绑定,shell脚本
- 项目遇到的问题小记
- Threadlocal 源码分析与内存泄漏
- Redis 安装(一)
- 特征工程框架图
- like模糊查询的占位符使用
- CentOS6.5启停脚本例子
- Centos6.5+mysql5.6+cluster7.4安装配置方案
- 阿里云服务器ECS添加数据盘
- TortoiseGit之配置密钥
- windows下使用TortoiseGit在Git@OSC代码托管
- VMware下安装CentOS6.5
- VMware下CentOS6.5安装oracle11g RAC
- 阿里云ECS CentOS6.5 LVM分区磁盘限额问题记录
- 采用类加载器解决jar hell(jar冲突)有关问题