自定义init.d服务

linux自定义服务并设置开机自启动

服务路径 /etc/init.d/

服务脚本

#!/bin/sh
#chkconfig: 2345 80 05
#description: api-server

start() {
	nohup java -jar ./
}

stop() {
		
}

status() {
	`ps -ef|grep `
}

case $1 in 
start)
	start
	;;
stop)
	stop
	;;
restart)
	stop
	sleep 1
	start
	;;
*) 
	echo "api-server Usage:"
	echo "service api-server start | stop | restart | status"
	;;

服务添加

mv api-server /etc/init.id/

chkconfig --list //查看服务
chkconfig --add api-server //添加服务

服务启动

service api-server status
service api-server start
service api-server stop
posted @ 2020-07-10 12:33  pengsn  阅读(497)  评论(0编辑  收藏  举报