自动运行程序shell脚本

Posted byxdaz

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自动运行程序shell脚本相关的知识,希望对你有一定的参考价值。

运行程序脚本,比如runHttpServer.sh

BASE_PATH=$(cd `dirname $0`;pwd)
cd $BASE_PATH
LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH
PATH=./:$PATH
export LD_LIBRARY_PATH PATH

chmod +x HttpServer
./HttpServer

停止运行程序脚本,比如stopHttpServer.sh

ps -aux | grep HttpServer | awk 'print $2' | xargs kill

后台运行程序脚本,比如runHttpServer_nohup.sh

BASE_PATH=$(cd `dirname $0`;pwd)
cd $BASE_PATH
LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH
PATH=./:$PATH
export LD_LIBRARY_PATH PATH

mv HttpServer.outfile HttpServer1.outfile
rm -f HttpServer.outfile
chmod +x HttpServer
nohup ./HttpServer > HttpServer.outfile 2>&1 &

 

以上是关于自动运行程序shell脚本的主要内容,如果未能解决你的问题,请参考以下文章