当前位置: 技术问答>linux和unix
服务启动脚本的错误
来源: 互联网 发布时间:2016-02-06
本文导语: 在/usr/local/bin下面放好了可执行程序,参照了/etc/init.d/ypxfrd ,稍微改了一下,写成了下面这个脚本,运行这个脚本(取名为teststart),red hat 9.0下报错,说无这个文件或者目录/etc/rc.d/init.d/functions! 我去此目录下看了,存在...
在/usr/local/bin下面放好了可执行程序,参照了/etc/init.d/ypxfrd ,稍微改了一下,写成了下面这个脚本,运行这个脚本(取名为teststart),red hat 9.0下报错,说无这个文件或者目录/etc/rc.d/init.d/functions! 我去此目录下看了,存在该文件,并且我用shell 运行ypxfrd,可以正常执行. 可我只是修改了几处地方.下面是我改写的脚本,我第一次写这东西,想必还有其他错误.请高手指教
#!/bin/bash
#
# Elink DG: Starts the Elink DG
#
# Version: @(#) /etc/init.d/elinkdg 1.0
# Source function library.
[ -f /etc/rc.d/init.d/functions ] || exit 0
. /etc/rc.d/init.d/functions
# The application programe path.
# add sosdairs
[ -f /usr/local/bin/elinkdg] || exit 0
RETVAL=0
start() {
echo -n $"Starting Elink DG server: "
# modify by sosdairs
# here has a error? YPXFRD_ARGS?
daemon elinkdg $YPXFRD_ARGS
ETVAL=$?
echo
# modify by sosdairs
[ $RETVAL -eq 0 ] && touch /usr/local/bin/elinkdginfo
return $RETVAL
}
stop() {
echo -n $"Stopping Elink DG server: "
killproc elinkdg
RETVAL=$?
# modify by sosdairs
[ $RETVAL -eq 0 ] && rm -f /usr/local/bin/elinkdginfo
echo
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status rpc.ypxfrd
;;
restart|reload)
stop
start
;;
condrestart)
if [ -f /usr/local/bin/elinkdginfo ]; then
stop
start
fi
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
exit 1
esac
exit $RETVAL
#!/bin/bash
#
# Elink DG: Starts the Elink DG
#
# Version: @(#) /etc/init.d/elinkdg 1.0
# Source function library.
[ -f /etc/rc.d/init.d/functions ] || exit 0
. /etc/rc.d/init.d/functions
# The application programe path.
# add sosdairs
[ -f /usr/local/bin/elinkdg] || exit 0
RETVAL=0
start() {
echo -n $"Starting Elink DG server: "
# modify by sosdairs
# here has a error? YPXFRD_ARGS?
daemon elinkdg $YPXFRD_ARGS
ETVAL=$?
echo
# modify by sosdairs
[ $RETVAL -eq 0 ] && touch /usr/local/bin/elinkdginfo
return $RETVAL
}
stop() {
echo -n $"Stopping Elink DG server: "
killproc elinkdg
RETVAL=$?
# modify by sosdairs
[ $RETVAL -eq 0 ] && rm -f /usr/local/bin/elinkdginfo
echo
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status rpc.ypxfrd
;;
restart|reload)
stop
start
;;
condrestart)
if [ -f /usr/local/bin/elinkdginfo ]; then
stop
start
fi
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
exit 1
esac
exit $RETVAL
|
报错,说无这个文件或者目录。
说明你的/usr/local/bin不在搜索路径中。
export PATH=$PATH:/usr/local/bin
说明你的/usr/local/bin不在搜索路径中。
export PATH=$PATH:/usr/local/bin
|
你stop的时候成功了吗?能用stop能调用killproc那么start就能调用daemon。
如果stop成功,那就不是用daemon这个命令的路径问题,改写成
daemon /usr/local/bin/elinkdg 看看
要是还不行就sh调试进入deamon函数看看。我没装Elink,没法实际调试你的脚本。
如果stop成功,那就不是用daemon这个命令的路径问题,改写成
daemon /usr/local/bin/elinkdg 看看
要是还不行就sh调试进入deamon函数看看。我没装Elink,没法实际调试你的脚本。