I have a bash script which is on serverA. This script will ssh to serverB and runs yarn top command, pulls the metrics and put into the file(test.txt) on serverA. Below is the command which I am using:
ssh -oStrictHostKeyChecking=no -i <key> username@hostname "yarn top" | head -5 | grep -w 'Applications' | awk '{print "Pending_apps" "\t" $7}' >> test.txt
So here the problem is that after my script runs above command it goes into interactive mode and it only exits when I give Ctrl+C or quit signal/command manually.
Is there any way through which after running the above command and redirecting the output to test.txt the script should move to the next command. That is after running the above command on the command prompt it should redirect output to a test.txt file and then should return back to command prompt/terminal