-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_ctrl.sh
executable file
·40 lines (38 loc) · 1.12 KB
/
service_ctrl.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# @Author: xiaofeng
# @Date: 2021-02-1 09:44:45
# @Last Modified by: xiaofeng
# @Last Modified time: 2021-02-1 09:44:45
server_path=./
server_name=iponline
case $1 in
start)
nohup $server_path$server_name >/dev/null 2>&1 &
echo "$server_name服务已启动..."
sleep 1
;;
stop)
killall $server_name >/dev/null 2>&1
echo "$server_name服务已停止..."
sleep 1
;;
status)
if [ $(pidof $server_name|wc -w) -eq 0 ] ;then
echo "$server_name服务未运行..."
else
echo "$server_name服务正在运行..."
fi
sleep 1
;;
restart)
killall $server_name >/dev/null 2>&1
sleep 1
nohup $server_path$server_name >/dev/null 2>&1 &
echo "$server_name服务已重启..."
sleep 1
;;
*)
echo "$0 {start|stop|status|restart}"
exit 4
;;
esac