Reputation: 308
I currently have a Jenkins job that does the following successfully:
1: Check for new commits in git repo ✓
2: clone repo ✓
3: Build repo jar with maven ✓
4: scp jar to remote server ✓
The 5th step is to run the jar, I am currently doing something like:
nohup ssh user@remotehost "java -jar some.jar" > /dev/null 2>&1
This works technically, it will run the jar, however the jenkins job is not finishing, I assume it is waiting for an exit code.
What I wish to achieve is, fire a command to a remote server over ssh without waiting for a response or output. I'm not sure if this is possible, is there a better way to do this?
Upvotes: 4
Views: 2676
Reputation: 180
You can try using the screen
command:
screen -d -m ssh user@remote "java -jar -Dserver.port=9090 ~/jar.jar"
From manual:
-d -m Start screen in "detached" mode. This creates a new session but doesn't attach to it. This is useful for system startup scripts.
Upvotes: 1