u012398614
SHU-Zhou
2017-04-21 02:51

Linux远程执行sh脚本出错

  • 脚本
  • tomcat
  • linux
  • command

首先我在一台机器上执行一个脚本,能在本机正常执行成功,脚本的功能为删除之前的war包备份文件,解压最新war包并通过发布到tomcat上
截取片段片段为
#/usr/bin/sh

if [ -d /opt/apache-tomcat-7.0.41/publish/testbak ]
then
echo "delete testbak"
rm -rf /opt/apache-tomcat-7.0.41/publish/testbak
fi

if [ -f /opt/apache-tomcat-7.0.41/publish/test.war ]
then
mkdir /opt/apache-tomcat-7.0.41/publish/test
echo "mkdir success"
mv /opt/apache-tomcat-7.0.41/publish/test.war /opt/apache-tomcat-7.0.41/publish/test
cd /opt/apache-tomcat-7.0.41/publish/test
jar xf /opt/apache-tomcat-7.0.41/publish/test/test.war
mv /opt/apache-tomcat-7.0.41/publish/test/test.war ..
cd ..

else
echo "test.war does not exist, quit"
exit 1
fi

echo "stop tomcat..."
cd ../bin
sh shutdown.sh

然后我通过ssh usr@ip "cd 脚本路径 ; ./test.sh"
它就报错了

 test.sh: line 21: jar: command not found
stop tomcat...
/opt/apache-tomcat-7.0.41/bin/catalina.sh: line 438: /was/jdk/jdk1.6.0_35/bin/java: No such file or directory
cp: cannot stat `testbak/WEB-INF/classes/*.properties': No such file or dire_ctory

我这边也用了绝对路径,不清楚为何会报这样的错

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答