标签:自定义服务
模仿/etc/rc.d/init.d下的任意一个文件的内容,写一个新的文件,名字和你的servicename的名字一样,然后执行
chkconfig --add servicename
执行成功后,编辑servicename文件,
例如:
#!/bin/bash # whoami # root # chkconfig: 345 51 49 # description: starts the jboss deamons # JBOSS_HOME=/usr/java/jboss JBOSS_OWNER=root case "$1" in ‘start‘) echo -n "Starting jboss: " su - $JBOSS_OWNER -c "$JBOSS_HOME/bin/run.sh" & touch /var/lock/subsys/jboss echo ;; ‘stop‘) echo -n "shutting down jboss! " su - $JBOSS_OWNER -c "kill -9 $(ps -ef | grep jboss | grep java | awk ‘{print $2}‘)" rm -f /var/lock/subsys/jboss echo ;; ‘restart‘) echo -n "restarting jboss: " $0 stop $0 start echo ;; *) echo "usage: jboss { start | stop | restart }" exit 1 esac exit 0
标签:自定义服务
原文地址:http://liuya2012.blog.51cto.com/1297306/1591210