Khaled
Khaled

Reputation: 563

Bash script how to run a command remotely and then exit the remote terminal

I'm trying to execute the command:

ssh nvidia@ubuntu-ip-address "/opt/ads2/arm-linux64/bin/ads2 svcd&"

This works so far except that it hangs in the remote terminal when "/opt/ads2/arm-linux64/bin/ads2 svcd&" is executed, unless i enter ctrl+c. So I'm looking for a command that, after executing the command, exits from the remote terminal and continue executing the local bash script.

thanks in advance

Upvotes: 0

Views: 1098

Answers (1)

louigi600
louigi600

Reputation: 743

When you run a command in background on a terminal, regardless of weather it be local or remotely, if you attempt to logout most systems will warn you have running jobs. One further attempt to logout and your jobs get killed as you exit. In order to avoid this you need to detach your running jobs from terminal. if job is already running you can

disown -h <jobspec ar reported by jobs>

If you want to run something in background and then exit leaving it running you can use nohup

nohup command &

This is certainly ok on init systems ... not sure if it works exactly like this on systems that use systemd.

Upvotes: 2

Related Questions