我是maven scala插件使用的zinc增量编译器的铁杆粉丝,但我发现每次弹出我的笔记本电脑时都必须手动启动它,这让我很恼火。我写了一个脚本在Ubuntu中将其作为服务运行-它启动正常,但当我运行mvn install时,我得到一个错误,指出它找不到程序javac。下面是我在/etc/init.d中的脚本-注意:我指定了$JAVA_HOME并将其添加到/etc/bash.bashrc中的路径中,该路径显式地来源于此脚本。
#!/bin/bash
### BEGIN INIT INFO
# Provides: zinc
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start compiler at boot time
# Description: Starts and stops the zinc incremental compiler
### END INIT INFO
source /etc/bash.bashrc
PROG_PATH="/opt/zinc/bin"
PROG="zinc"
start() {
su - gary "-c $PROG_PATH/$PROG -start 2>&1 >/dev/null &"
echo "$PROG started"
}
stop() {
su - gary "-c $PROG_PATH/$PROG -shutdown 2>&1 >/dev/null &"
echo "$PROG stopped"
}
## Check to see if we are running as root first.
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
case "$1" in
start)
start
exit 0
;;
stop)
stop
exit 0
;;
reload|restart|force-reload)
stop
start
exit 0
;;
**)
echo "Usage: $0 {start|stop|reload}" 1>&2
exit 1
;;
esac发布于 2012-12-04 15:34:10
Zinc带有-java-home命令参数。你试过那个吗?
https://stackoverflow.com/questions/12470262
复制相似问题