Sponsored Content
Top Forums Shell Programming and Scripting Remote script via SSH not executing Post 302957818 by oraclermanpt on Thursday 15th of October 2015 03:49:56 PM
Old 10-15-2015
Code:
-bash-3.2$ /usr/bin/ssh -t -o stricthostkeychecking=no jboss@server1 "ls -l"
total 12
drwxr-xr-x 13 jboss mware 4096 Sep 16 15:55 EAP-6.4.0
drwxr-xr-x  8 jboss mware   85 Sep 16 16:05 XYZ
drwxr-xr-x  6 jboss mware 4096 Sep 16 16:04 java
drwxr-xr-x  2 jboss mware 4096 Oct 15 09:26 logs
-rw-r--r--  1 jboss mware    0 Oct 14 09:16 nohup.out
drwxr-xr-x  2 jboss mware   39 Oct 15 09:33 scripts
-rw-r--r--  1 jboss mware    0 Oct 13 16:36 t1
Connection to server1 closed.

-bash-3.2$ /usr/bin/ssh -t -o stricthostkeychecking=no jboss@server1 "/bin/sh ~/rootmemory.sh"
              total        used        free      shared  buff/cache   available
Mem:           3792         823         264          64        2704        2657
Swap:          8191           0        8191
Total:        11984         823        8456
Connection to server1 closed.

Invoke server1 script from server2

there is nohup in remote script shown below.

Code:
cd /apps/EAP-6.4.0
NODENAME=xyz; IP_ADDR=`hostname`; MGMT_IPADDR=`hostname`; offset=0
nohup ./bin/standalone.sh -Djboss.node.name=$NODENAME -Djboss.server.base.dir=../$NODENAME -b $IP_ADDR -bmanagement $MGMT_IPADDR --server-config=standalone.xml -Djboss.socket.binding.port-offset=$offset -Dcom.sun.management.jmxremote.port=4001 &
sleep 10

If I add sleep command in above.
Code:
ssh server1 sh ~/scripts/start_standalone.sh </dev/null >~/root-backup.log 2>&1 &

runs as backend on server2. even I kill backend process on server2. java process runs on server1(remote host).

remove sleep command doesn't start remote process.

---------- Post updated at 03:49 PM ---------- Previous update was at 11:24 AM ----------

issue is resolved. This may help others.

Code:
ssh server1  " sh ~/scripts/start_standalone.sh >console.log 2>&1"

Remote script

copied contents of .bash_profile to .bashrc

Code:
cd $JBOSS_HOME
NODENAME=xyz; IP_ADDR=`hostname`; MGMT_IPADDR=`hostname`; offset=0
nohup ./bin/standalone.sh -Djboss.node.name=$NODENAME -Djboss.server.base.dir=../$NODENAME -b $IP_ADDR -bmanagement $MGMT_IPADDR --server-config=standalone.xml -Djboss.socket.binding.port-offset=$offset -Dcom.sun.management.jmxremote.port=4001 &

SmilieSmilieSmilieSmilieSmilie

Last edited by oraclermanpt; 10-15-2015 at 12:33 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Executing awk in a remote server using ssh

Hello Everybody, I'm facing a weird problem with the awk command. I'm trying to execute a simple awk command as follows, echo 1 2 | awk '{print $2}' This command prints the output 2. When i try to execute the same command in a remote server using ssh as follows, ssh user@host... (2 Replies)
Discussion started by: karthikv
2 Replies

2. Shell Programming and Scripting

Executing a script on a remote system via SSH

Hello all, I have a relatively simple script I wrote to generate a count of errors broken down. What I would like to do is execute this script from another server so that I don't actually have to log in to the server to run the check. The script on what we'll call "Server A" is: ... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

3. UNIX for Dummies Questions & Answers

how to stay in remote shell after executing commands in ssh?

the ssh calling convention: ssh <server> If I put commands in the section, ssh will execute them immediately after logging in and return to local shell. I want to stay in the remote shell after executing these commands. How can I achieve this? Thanks for all. (1 Reply)
Discussion started by: hplonlien
1 Replies

4. Shell Programming and Scripting

Executing remote application using ssh without full reference to its location

Hello again :) , My script has an ssh command to run a script on a remote machine. The script has commands such as sqlplus and unzip. However, the return I get in my own terminal says it can't find sqlplus and unzip. the ssh command is: ssh user@host "cd ScriptDir; ./Script.sh" and the... (6 Replies)
Discussion started by: jangozo
6 Replies

5. Shell Programming and Scripting

executing command in a remote machine through ssh - shell script

Hi All, i have two machines like x and y . my requirement is i should connect to machine Y from x through ssh connection . and do some operation such as copy and move and delete files in Y machine . i tried with this code but it is doing in machine x only . and i need to exit from Y when... (1 Reply)
Discussion started by: rateeshkumar
1 Replies

6. Shell Programming and Scripting

executing commands in remote server using ssh

I have some commands which need to be executed in remote machine. I have Linux Server from where I need to connect to Solaris server using ssh and then declare some variable over there and run some commands. I don't want to call a script which is present in Solaris server from Linux server... (7 Replies)
Discussion started by: maitree
7 Replies

7. Shell Programming and Scripting

Executing remote commands via ssh

Hi, I'm tryin to write a script that will collect information about a remote servers, put them into variables and print them to screen. # /usr/bin/bash ls $1 > /dev/null 2>/dev/null if then echo "$1 is file" for server in $(cat $1) do # echo $server ... (5 Replies)
Discussion started by: moshesa
5 Replies

8. UNIX for Dummies Questions & Answers

Executing a script in remote server

Hi All, I have 2 servers A and B. I need to connect to server B from server A and execute a shell script in B which will create some files and i need to copy those files back to server A. Required easiest possible for perfoming above task. (1 Reply)
Discussion started by: Girish19
1 Replies

9. Linux

Executing a script in remote machine through ssh

How to execute a script in remote machine through ssh I have a script test.sh which does some backup activity in remote machine. Wanted to keep backup also in remote machine. ssh -l username <remote machine> "commands to be exceuted as ; separted" but how to put the script in the place of... (5 Replies)
Discussion started by: sanvel
5 Replies

10. Shell Programming and Scripting

Issue in executing cat (remote ssh)

Hi, I need to ssh remotely to a machine and cat a file assign the value to a variable Script: #!/bin/bash -x value=`cat config.txt` echo "$value" ssh me@xxx.host.com "valu='cat /export/home/test.md5'; echo "$valu"" | tee Execution: $ ./x ++ cat config.txt + value='touch me' +... (5 Replies)
Discussion started by: close2jay
5 Replies
All times are GMT -4. The time now is 06:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy