You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I have a question. I use SSHJ execute the command "nohup Java jar - server - Xms1g - Xmx1g - XX: XX: + UseG1GC - + UnlockExperimentalVMOptions - XX: G1NewSizePercent = 20 -XX:G1MaxNewSizePercent=30 -XX:+DisableExplicitGC /data/deploy/jar/nut-helloworld.jar --spring.profiles.active=dev >> /data/deploy/jar/nut-helloworld.log 2> &1&", returns a status code of 0, but it does not take effect. The same command that I wrote in the script worked when the script was executed
#868
Open
wzd-hash opened this issue
Jun 12, 2023
· 1 comment
public static Result execCommand(SSHClient ssh, String command,boolean isSudo){
Result r = new Result();
Session session = null;
try {
log.info("执行命令:" + command);
session = ssh.startSession();
Map<PTYMode, Integer> emptyMap = new HashMap<>();
session.allocatePTY("xterm", 80, 24, 0, 0, emptyMap );
command = getCommand(command, isSudo);
final Session.Command cmd = session.exec(command);
cmd.join(300, TimeUnit.SECONDS);
String runLog = IOUtils.readFully(cmd.getInputStream()).toString();
String errorLog = IOUtils.readFully(cmd.getErrorStream()).toString();
Integer exitStatus = cmd.getExitStatus();
r = handleResult(exitStatus, runLog, errorLog, command);
} catch (ConnectionException e) {
r.setStatus(-1);
r.handleErrorLog(e.getMessage());
r.setIsSuccess(false);
} catch (IOException e) {
r.setStatus(-1);
r.handleErrorLog(e.getMessage());
r.setIsSuccess(false);
} finally {
closeSession(session);
}
The text was updated successfully, but these errors were encountered: