自动运行程序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 &

 

©️2020 CSDN 皮肤主题: 技术工厂 设计师:CSDN官方博客 返回首页