【发布时间】:2019-03-29 08:36:12
【问题描述】:
我有一个在 Ubuntu 机器上运行的 Tomcat 网络服务器。如何从 gitlab-ci 通过 SSH 重新启动服务器?
我正在通过 gitlab-ci 上的 ssh 将各种 war & jar 文件部署到服务器,在某些情况下需要重新启动 Tomcat 服务器。
我尝试使用 tomcatctl 命令:
> ssh user@remote_ip tomcatctl stop
> bash: tomcatctl: command not found
> ssh user@remote_ip bash "tomcatctl stop"
> bash: tomcatctl: No such file or directory
我也试过写一个shell脚本并通过ssh调用它:
#!/bin/bash
tomcatctl stop
> ssh user@remote_ip './stopTomcat.sh'
> ./stopTomcat.sh: line 2: tomcatctl: command not found
看起来它正在客户端而不是远程服务器上执行远程脚本。 当我在服务器上打开终端时,所有命令和脚本都正常工作。
【问题讨论】:
标签: ubuntu ssh gitlab-ci tomcat9