Bash 스크립트를 통해 원격으로 명령을 실행한 다음 원격 터미널을 종료하는 방법

Bash 스크립트를 통해 원격으로 명령을 실행한 다음 원격 터미널을 종료하는 방법

다음 명령을 실행하려고 합니다.

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

"/opt/ads2/arm-linux64/bin/ads2 svcd&"ctrl+c를 입력하지 않는 한 실행 시 원격 터미널에서 정지된다는 점을 제외하면 지금까지는 작동합니다 (아래 이미지 참조).

여기에 이미지 설명을 입력하세요

"/opt/ads2/arm-linux64/bin/ads2 svcd &"그래서 명령을 실행한 후 원격 터미널에서 종료하고 로컬 bash 스크립트를 계속 실행하는 명령을 찾고 있습니다 .

아래는 내가 작업중인 bash 스크립트입니다.

#!/usr/bin/env bash

echo "Welcome to ADS2 Session Start..."

while  true 
do
echo "Starting service Daemon on the targert"
echo "Enter the ip-address of the target"
read x
if [ -z "$x" ]
then 
    echo "ip-address is empty"
else
    echo "Connecting with target..."
    if [[ $x =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ || $x =~ ^fdt-c-agx-[0-9][0- 
      9][0-9][0-9]$ ]]
    then
        ssh nvidia@"$x"   "/opt/ads2/arm-linux64/bin/ads2 svcd &"; exit 0 
        if ! ssh nvidia@"$x"
        then
            echo -e "\033[31mconnection failed\e[0m" 
        else
            echo -e "\033[32m connection succeded\e[0m"
        
            break
        fi
    else
        "Make sure the io address in the coorect form"  
    fi

fi
done

관련 정보