linux添加service服务,设置自启

举个栗子:idea的注册服务
位置及文件:/etc/init.d/idea
idea

#!/bin/sh
# chkconfig: 2345 80 90
# description: idea register server

case "$1" in
        start)
                sh /usr/local/idea/start.sh
        ;;
        stop)
                ps -ef |grep idea|grep -v grep|awk '{print $2}'|xargs kill
        ;;
esac

# chkconfig ,# description不要少,设置自启需要。

服务启动:service idea start
服务关闭:service idea shutdown
设置自启:chkconfig idea on
关闭自启:chkconfig idea off

原文地址:https://www.cnblogs.com/lidabo/p/14000620.html