我正在尝试在Ubuntu机器上启动时运行.jar文件,但我没有得到任何地方。我试过这里的说明https://askubuntu.com/questions/99232/how-to-make-a-jar-file-run-on-startup-and-when-you-log-out,我'尝试使用Upstart网站和食谱中的信息,但他们没有工作。我已经尝试了旧的SysV和新的Upstart方法,但它们都没有在系统启动时启动.jar。
这是运行.jar的shell脚本
#!/bin/bash
java -jar TransformationServer.jar
SysV启动方法的文件
#!/bin/bash
# Transformation Server
#
# Description: Transforms incoming messages on a given port and forwards them
case $1 in
start)
/bin/bash /usr/local/bin/ServerStart.sh
;;
stop)
/bin/bash /usr/local/bin/ServerStop.sh
;;
restart)
/bin/bash /usr/local/bin/ServerStop.sh
/bin/bash /usr/local/bin/ServerStart.sh
;;
esac
exit 0
UpStart方法
# transformationserver - transforms incoming http messages, and redirects them
#
# This service intercepts incoming http messages on a given port, and
# transforms them into an acceptable format in order to be received
# by a 3rd party service
start on runlevel [345]
stop on runlevel [!2345]
respawn
script
exec /bin/bash /home/ubuntu/TransformationServer/ServerStart.sh
# Also trying the below as well
#exec /bin/java -jar /home/ubuntu/TransformationServer/TransformationServer.jar
end-script
有更多使用这些方法的经验的人可以查看我的文件,并可能指出我正确的方向吗?这项服务是必需的,因此我们的公司系统可以成功接收来自我们客户的通信。
提前致谢。