1、vi /etc/init.d/glassfish3
export AS_JAVA=/usr/local/jdk1.6.0_11
GLASSFISHPATH=/root/glassfish3/bin
export PASSWD=/root/glassfish3/bin/.passwd
case "$1" in
start)
echo "starting glassfish from $GLASSFISHPATH"
su - root $GLASSFISHPATH/asadmin start-domain
;;
status)
$0 start
;;
restart)
$0 stop
$0 start
;;
stop)
echo "stopping glassfish from $GLASSFISHPATH"
su - root $GLASSFISHPATH/asadmin stop-domain
;;
*)
echo $"usage: $0 {start|stop|restart|status}"
exit 3
;;
esac
2、sudo chmod +x /etc/init.d/glassfish3
3、vi /root/glassfish3/bin/.passwd
AS_ADMIN_PASSWORD=administration-password
请将 administration-password修改成你自己的密码
4、chkconfig glassfish3 on
5、chkconfig --list glassfish3
来源:oschina
链接:https://my.oschina.net/u/143872/blog/64815