首页 > 解决方案 > Run jar on remote machine as background process over ssh

问题描述

I want to run a jar as a background process on a remote machine over ssh connection. There is bash script on remote machine to execute jar

#!/bin/sh
export JAVA_HOME=/location/of/java/
export PATH=$JAVA_HOME/bin:$PATH
nohup java -jar jar_name.jar config.properties &

If I execute the above script directly from remote machine(sudo ./start_script.sh), jar is started as background process and stdout is directed to nohup.out in the same folder as jar. But when I run script from local machine : ssh vm_name 'sudo ./start_script.sh', the process starts up. but it blocks and the output is directed to local terminal.

is there way to achieve this?

EDIT: I need to run script as root and also pass parameters to script, added placeholder path for JAVA_HOME to avoid confusion

标签: javabashssh

解决方案



推荐阅读