shell脚本触发与程序日志打印位置

针对近期的一个项目部署,每次通过一键启动脚本来启动程序时,发现日志都是生成在外层目录而不是程序目录里。

如上图,本应在deploy/ecity-http目录下的log,生成在deploy目录下。

执行脚本start-all如下:

sh /home/ecity/deploy/eureka/start-eureka.sh
sleep 15s
sh /home/ecity/deploy/ecity-grpc/start-grpc.sh
sleep 30s
sh /home/ecity/deploy/ecity-http/start-http.sh
是由delpoy目录下的总脚本触发分目录下的脚本。

问题原因:日志生成目录为脚本执行目录。

解决办法:1、修改程序日志生成目录为绝对路径,优点:简单,有效;缺点:每个不同的服务器下都得修改目录,比较繁琐

     2、脚本解决,先进触发脚本所在的目录,然后再去执行脚本。

cd /home/ecity/deploy/eureka/
sh start-eureka.sh
sleep 15s
cd /home/ecity/deploy/ecity-grpc/
sh start-grpc.sh
sleep 25s
cd /home/ecity/deploy/ecity-http/
sh start-http.sh

 

posted @ 2017-11-07 11:03  乐在跑途  阅读(835)  评论(0编辑  收藏  举报