fedora 13 init.d 脚本,无法停止
我编写了 init.d 脚本来运行 java CLI 进程。
问题是,当我停止它时,我[失败]并且进程仍在运行。
谢谢
#!/usr/bin/env bash
#
# chkconfig: 345 97 03
#
# processname: quotes-srv
#
#
# source function library
. /etc/rc.d/init.d/functions
NAME=quotes-srv
start() {
echo -n $"Starting $NAME: "
daemon +19 java -Dlog4j.configuration="file:/opt/quotes/properties/log4j/log4j.properties" -Dproperties_folder="/opt/quotes/properties/app/" -jar /opt/quotes/trade-0.0.1-SNAPSHOT-jar-with-dependencies.jar &
touch /var/lock/subsys/$NAME
}
stop() {
echo -n $"Stopping $NAME: "
killproc $NAME
echo
rm -f /var/lock/subsys/$NAME
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload|reload)
restart
;;
condrestart|try-restart)
[ -f /var/lock/subsys/$NAME ] && restart
;;
status)
status $NAME
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
exit 1
esac
exit 0
I wrote init.d script that suppose to run java CLI proccess.
The problem is that when i stop it, i get [failed] and the proccess is still running.
thanks
#!/usr/bin/env bash # # chkconfig: 345 97 03 # # processname: quotes-srv # # # source function library . /etc/rc.d/init.d/functions NAME=quotes-srv start() { echo -n $"Starting $NAME: " daemon +19 java -Dlog4j.configuration="file:/opt/quotes/properties/log4j/log4j.properties" -Dproperties_folder="/opt/quotes/properties/app/" -jar /opt/quotes/trade-0.0.1-SNAPSHOT-jar-with-dependencies.jar & touch /var/lock/subsys/$NAME } stop() { echo -n $"Stopping $NAME: " killproc $NAME echo rm -f /var/lock/subsys/$NAME } restart() { stop start } case "$1" in start) start ;; stop) stop ;; restart|force-reload|reload) restart ;; condrestart|try-restart) [ -f /var/lock/subsys/$NAME ] && restart ;; status) status $NAME ;; *) echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}" exit 1 esac exit 0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Killproc 将终止进程列表中与名称 $NAME 匹配的程序
严格来说,这就是您的情况 java 。
如果它是唯一的 java 进程,您可以将 java 放入 $NAME
如果您运行其他 java 服务,则必须找到另一种方法来停止 java 进程,例如将 PID 放入 /var/lock/subsys/$NAME 文件中然后使用pid杀死进程。
至少在 debian 上有一个很好的工具可以帮助解决这个问题,但我不确定它是否存在
红帽。
killproc will terminate programs in the process list which match the name $NAME
Strictly speaking this is in your case java .
If it is the only java process you can go and put java in $NAME
If you run other java services you have to find another way to stop your java process, e.g. putting the PID in the /var/lock/subsys/$NAME file and then killing the process using the pid.
On at least debian there is a nice tool which helps with this, but I am not sure it exists for
redhat.