nginx服务启动脚本
- 创建脚本
[root@jun init.d]# cat nginx
#!/bin/bash
# chkconfig: 2345 20 80
# description: aassddf
case $1 in
'stop'|'STOP')
/usr/local/nginx/sbin/nginx -s stop
;;
'start'|'START')
/usr/local/nginx/sbin/nginx
;;
'restart'|'RESTART')
/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx
;;
'reload'|'RELOAD')
/usr/local/nginx/nginx -s reload
;;
*)
echo 'Usage:service nginx stop|restart|start|reload'
esac
[root@jun init.d]#
- 把脚本cp到/etc/init.d/目录下
[root@jun ~]# mv nginx.sh /etc/init.d/nginx
- 给脚本执行权限
[root@jun init.d]# chmod +x nginx
[root@jun ~]# ll /etc/init.d/nginx -d
-rwxr-xr-x. 1 root root 434 2月 28 19:00 /etc/init.d/nginx
5.用脚本启动服务
[root@jun ~]# service nginx start
[root@jun ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 *:10050 *:*
LISTEN 0 128 *:10051 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 80 :::3306 :::*
[root@jun ~]#