我尝试了以下方法,但收效甚微:
$ ssh -t server-name sudo -H -u myuser sh /catalina/home/path/bin/catalina.sh start
Using CATALINA_BASE: /catalina/home/path
Using CATALINA_HOME: /catalina/home/path
Using CATALINA_TMPDIR: /catalina/home/path/temp
Using JRE_HOME: /usr/lib/jvm/java-1.8.0-openjdk-amd64
Using CLASSPATH: /catalina/home/path/../extraclasspathfiles:/catalina/home/path/bin/bootstrap.jar:/catalina/home/path/bin/tomcat-juli.jar
Tomcat started.
$ ssh -t server-name 'ps ax | grep java'
24322 pts/0 S+ 0:00 grep --color=auto java
没有运气
这是remote.sh(位于服务器上)的内容
#!/bin/sh
export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-amd64"
export CATALINA_HOME="/catalina/home/path"
/catalina/home/path/bin/startup.sh
然后我们远程运行脚本
$ ssh -t server-name sudo -H -u myuser sh /catalina/home/path/bin/remote.sh/bin/remote.sh
Using CATALINA_BASE: Using CATALINA_BASE: /catalina/home/path
Using CATALINA_HOME: Using CATALINA_HOME: /catalina/home/path
Using CATALINA_TMPDIR: Using CATALINA_TMPDIR: /catalina/home/path/temp/temp
Using JRE_HOME: /usr/lib/jvm/java-1.8.0-openjdk-amd64
Using CLASSPATH: Using JRE_HOME: /usr/lib/jvm/java-1.8.0-openjdk-amd64/../extraclasspathfiles:Using CLASSPATH: /catalina/home/path/../extraclasspathfiles:/catalina/home/path/bin/bootstrap.jar:/catalina/home/path/bin/tomcat-juli.jar/bin/bootstrap.jar:Tomcat started./bin/tomcat-juli.jar
Tomcat started.
$ ssh -t server-name 'ps ax | grep java'
24322 pts/0 S+ 0:00 grep --color=auto java
再次,没有运气
我在这里想念什么?
答案 0 :(得分:1)
您正在server-name
上启动Tomcat并在本地执行ps
。
要查看Java是否在远程计算机上运行
ssh -t server-name 'ps ax | grep java'
答案 1 :(得分:0)
我找到了答案:
ssh server-name sudo -H -u username sh /path/to/generated/bin/startup.sh
-t
引起了问题。
-t Force pseudo-terminal allocation. This can be used to execute arbitrary screen-based programs on a remote machine,
which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh
has no local tty.