1-在/etc/rc.local中配置开机自启动
su - sumapay25 -c "/opt/glassfish.sh start 1"
2-/opt/glassfish.sh脚本如下
#!/bin/sh
ASADMIN="/home/sumapay25/glassfish4/glassfish/lib/nadmin"
case "$1" in
start)
$ASADMIN start-domain --domaindir /home/sumapay25/glassfish4/glassfish/domains domain1 &
;;
stop)
$ASADMIN stop-domain --domaindir /home/sumapay25/glassfish4/glassfish/domains domain1 &
;;
restart)
$ASADMIN restart-domain --domaindir /home/sumapay25/glassfish4/glassfish/domains domain1 &
;;
*)
echo "usage: $0 (start|stop|restart|help)"
esac