shell 服務啟動指令碼的編寫

2021-10-02 21:32:28 字數 1174 閱讀 6146

首先在官網獲得nginx的安裝包

tar zxf nginx-1.16.1.tar.gz

cd nginx-1.16.1/

yum install gcc zlib zlib-devel openssl-devel -y #解決依賴性

當看到makefile和objs時說明安裝成功

/usr/local/nginx/sbin/nginx 			#啟動

/usr/local/nginx/sbin/nginx -s stop #關閉

netstat -antlpe | grep nginx |wc -l #檢視埠狀態(0表示關閉,1表示開啟)

vim /etc/init.d/nginxd
指令碼內容:

#!/bin/bash

. /etc/init.d/functions #載入系統函式庫

path=/usr/local/nginx/sbin #設定nginx啟動命令路徑

function start()

function stop()

case "$1" in #通過特殊引數$1接收指令碼引數的字串

start)

start

;; stop)

stop

;; restart)

stop

sleep 1

start

;; *)

echo $"usage: $0 "

exit 1

esac

exit $retval

給它加上執行許可權:

chmod +x /etc/init.d/nginxd
測試:

shell 編寫nginx啟動指令碼

ubuntu16.04編譯安裝nginx1.13 sudo apt install y build essential sudo apt install y libtool sudo apt install y libpcre3 libpcre3 dev sudo apt install y zli...

shell啟動指令碼

由於客戶特殊需求,公升級軟體時自動修改sf,無需手動,給他們在啟動指令碼裡面新增了修改sf的指令。正好記下。f 2 2 sfdst ls usr s304 etc oversea 3if sfsrc sfdst then 4echo sfcfgname is not right 5 s sfcfgn...

shell程式設計 nginx 服務的啟動指令碼

bin bash nginx this shell script takes care of starting and stopping standalone nginx.config usr local nginx conf nginx.conf source function library.e...