shell编写 ngin启动脚本

#!/bin/bash

[ -f /etc/init.d/functions ] && . /etc/init.d/functions

pid=/application/nginx/logs/nginx.pid

nginx=/application/nginx/sbin/nginx

RED_COLOR=‘\E[1;31m‘

GREEN_COLOR=‘\E[1;32m‘

YELLOW_COLOR=‘\E[1;33m‘

BLUE_COLOR=‘\E[1;34m‘

PINK=‘\E[1;35m‘

SHAN=‘\E[31;5m‘

RES=‘\E[0m‘

start(){

if [ -f $pid ]; then

action "nginx 正在运行的" /bin/false

else

$nginx

action "nginx 启动" /bin/true

fi

}

stop(){

if [ ! -f $pid ]; then

action "nginx 已经停止了" /bin/false

else

$nginx -s stop

action  "nginx 停止" /bin/true

fi

}

reload(){

if [ ! -f $pid ]; then

action "nginx 已经停止了" /bin/false

else

$nginx -s reload

action "nginx 已重启" /bin/true

fi

}

case "$1" in

start)

start

;;

stop)

stop

;;

reload)

reload

;;

restart)

stop

sleep 2

start

;;

*)

echo -e "${SHAN}脑残这是例子 :$0 (stop|start|reload|restart)$RES"

esac

时间: 2024-08-06 05:40:15

shell编写 ngin启动脚本的相关文章

用shell写ngin启动脚本

#!/bin/bash [ -f /etc/init.d/functions ] && . /etc/init.d/functions pid=/application/nginx/logs/nginx.pid nginx=/application/nginx/sbin/nginx RED_COLOR='\E[1;31m' GREEN_COLOR='\E[1;32m' YELLOW_COLOR='\E[1;33m' BLUE_COLOR='\E[1;34m' PINK='\E[1;35m'

Python中的类方法及属性总结举例,编写memcached启动脚本举例

1.类的属性总结类属性,也是公有属性, 类的私有属性, 对象的共有属性, 对象的私有属性, 内置属性, 函数的局部变量, 全局变量, #/usr/bin/env python # -*- coding:utf-8 -*- class MyClass(object): var1 = '类属性,类的公有属性 var1' __var2 = '类的私有属性 __var2' def func1(self): self.var3 = '对象的公有属性 var3' self.__var4 = '对象的私有属性

linux shell 之尝试编写 企业级 启动脚本

企业Shell面试题10:开发企业级MySQL启动脚本 说明: MySQL启动命令为: 1 /bin/sh mysqld_safe --pid-file=$mysqld_pid_file_path 2>&1 >/dev/null & 停止命令逻辑脚本为: 1 2 3 4 5 6 mysqld_pid=`cat "$mysqld_pid_file_path"` if (kill -0 $mysqld_pid 2>/dev/null)   then    

nginx 源码编译安装并编写服务启动脚本

1. 使用xshell将nginx源码包上传到server 2. 安装依赖的软件包工具 zlib-devel?? pcre-devel?? gcc? gcc-c++ yum -y install zlib-devel pcere-devel gcc gcc-c++ 验证一下: 3. 指定nginx的运行用户 (创建nginx用户不使其登录系统.-M不创建宿主目录) [[email protected] ~]# useradd -s /sbin/nologin -M nginx 4. 编译安装ng

Shell开发rsync启动脚本

需求:实现shell脚本对rsync的start|stop|restartrsync pid所在路径:/var/run/rsyncd.pidrsync启动命令:rsync --daemonrsync进程停止命令:pkill rsync 文中通过判断rsync pid所在路径和进程状态来实现rsync的start|stop|restart 1)脚本演示 [[email protected] scripts]# cat rsync.sh #!/bin/sh #This is the launch s

用Shell编写项目发布脚本

1.首先在github上创建一个测试用的仓库 2.本地编写一个可以运行的测试项目,上传至github 3.链接服务器,编写脚本如下:注意:编写前需要在服务器上安装git和maven 执行build_code方法,从github上克隆下新上传的项目 进入到项目目录下,执行maven命令打包 进入到tomcat目录下,删除Root文件夹和Root.war将项目打好的war包从指定目录拷贝到tomcat的webapps目录下重命名为ROOT.war进入tomcat /bin目录下重启tomcat 4.

Python编写的memcached启动脚本

Python编写memcached启动脚本 一.rc 脚本的start.stop.restart.status方法 #/usr/bin/env python # -*- coding:utf-8 -*- # @time   :2018/1/12 19:11 # @Author :FengXiaoqing # @file   :rc.py import os import sys from subprocess import Popen,PIPE class Process(object):   

Python - 利用python编写的memcached启动脚本

memcached作为缓存文件服务,默认是操作系统里面是可以直接yum -y install memcached进行安装的. /etc/init.d/memcached 是属于系统shell编写的管理脚本,下面这个脚本是python脚本编写出来的memcached管理脚本,和shell编写的脚本实现的效果一样. #!/usr/bin/python import sys import os from subprocess import Popen,PIPE class Process(object

nginx启动脚本编写及设置开机自启动

环境:Centos 6.8 如果机器是Centos 7的,此脚本和设置开机自启动方法不适用. 首先确保nginx配置文件中:有pid目录 pid        logs/nginx.pid; 1.1 编写nginx启动脚本 [[email protected] ~]# cd /server/scripts [[email protected] scripts]# vim nginx.sh  #!/bin/bash [ -f /etc/init.d/functions ] && . /etc