Jump to content

RHEL6 ssh cannot start a remote background process


Recommended Posts

Guest ndrw_cheung
Posted

Hi. I�m using RHEL6 (version 6.5) on all servers and I came across a problem invoking a process in the background via ssh. The set up is as follows:

 

Server 1 :

Script : start.sh:

#!/bin/sh

ssh user1_AT_x.x.x.x �t sudo �/etc/init.d/test1�

#note : I cannot post the "at" sign due to being a new user, so _AT_ is the at sign

Server 2 :

Script : /etc/init.d/test1:

#!/bin/sh

./runremote.sh &

 

 

user1 exist on both server 1 and server 2 has sudo privileges.

 

When we do (logged in as user1 and sudo on server 1)�./start.sh� from Server 1, the script �runremote.sh� is NOT invoked. I tried removing the �&� to run runremote.sh in the foreground. That works, but the start.sh hangs and will not close the ssh connection. I also tried the following variations, but none of them work the way I wanted:

�nohup ./runremote.sh�

�nohup ./runremote.sh &�

�./runremote.sh > /var/log/runremote.log 2>&1�

�./runremote.sh < /dev/null > /var/log/runremote.log 2>&1�

 

 

How should I change the contents of these scripts so that when I do �./start.sh�, �runremote.sh� is invoked in the background and �start.sh� will close the ssh connection afterwards? If possible, I DON�T want to use any additional software such as �screen�.

Thanks in advance for answering.

 

-Andrew

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...