Chinaunix

标题: 关于环境变量的一个问题 [打印本页]

作者: yym314    时间: 2006-11-16 11:33
标题: 关于环境变量的一个问题
我在linux下写了个服务器程序,需要用到一个LD_LIB_PATH这样的环境变量.我在/etc/profile文件中定义了这个环境变量,并export出来.运行程序,一切OK.

现在我在/etc/rc.d/init.d这个目录下,写了过脚本myloader用于启动这个程序
然后我用service myloader start命令启动这个程序.
程序能起来,但是有个奇怪的问题.我在程序中通过environ把这个环境变量表显示出来.发现整个环境变量表只有3,4项.我定义的那个LD_LIB_PATH并没有在其中.
请问这是怎么回事情啊?

我的脚本是这样写的
#!/bin/bash
#
# chkconfig: 2345 25 85
# description: start and stop myloader
#
#

mldir=/home/myloader/
echo "$mldir"
[ -d $mldir ] || exit 0

start() {
        cd "$mldir"
        if [ -e myloader];then
                ./myloader -daemon >/dev/null
        else
                echo "myloader is not in dir $mldir"
        fi

        echo "myloaderstart completed"
}

stop() {
        pid=$( ps -ef|grep myloader|awk '{print $2}'|head -n 1)
        echo $pid
        kill -9 $pid
        echo "myloader stop completed"
}

restart() {
        stop
        sleep 1
        start
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart}"
esac




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2