fixunix
Tags Register FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

Use ssh command to *invoke* long running process on remote machine. - SSH

This is a discussion on Use ssh command to *invoke* long running process on remote machine. - SSH ; Hi all, I'm wondering if I can use the ssh command in Ubuntu to invoke a long running process on a remote machine and when the process has been invoked to break the ssh connection. I am writing a python ...


Fix Unix > Technologies & Tools > Protocols > SSH > Use ssh command to *invoke* long running process on remote machine.

Reply
 
LinkBack Tools
  #1  
Old 10-24-2008, 02:19 PM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Use ssh command to *invoke* long running process on remote machine.

Hi all,

I'm wondering if I can use the ssh command in Ubuntu to invoke a long
running process on a remote machine and when the process has been
invoked to break the ssh connection.

I am writing a python script that needs this functionality.

What I've come up with (that doesn't work) is:

ssh -i ~/ssh/backup_key user@140.203.3.143 "nohup python /home/user/
longProcess.py &"


This allows me to ssh to the remote machine without a password, but
the ssh connection doesn't break until the "longProcess.py" is
finished.

Hopefully somebody can give me a hint here.

Thanks!
Reply With Quote
  #2  
Old 10-24-2008, 07:04 PM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: Use ssh command to *invoke* long running process on remote machine.

sophie_newbie wrote:
> Hi all,
>
> I'm wondering if I can use the ssh command in Ubuntu to invoke a long
> running process on a remote machine and when the process has been
> invoked to break the ssh connection.
>
> I am writing a python script that needs this functionality.
>
> What I've come up with (that doesn't work) is:
>
> ssh -i ~/ssh/backup_key user@140.203.3.143 "nohup python /home/user/
> longProcess.py &"
>
>
> This allows me to ssh to the remote machine without a password, but
> the ssh connection doesn't break until the "longProcess.py" is
> finished.
>
> Hopefully somebody can give me a hint here.
>
> Thanks!


Why not simply take the '&' off the end?
Reply With Quote
  #3  
Old 10-25-2008, 02:57 AM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: Use ssh command to *invoke* long running process on remote machine.

Nico Kadel-Garcia writes:

>sophie_newbie wrote:
>> Hi all,
>>
>> I'm wondering if I can use the ssh command in Ubuntu to invoke a long
>> running process on a remote machine and when the process has been
>> invoked to break the ssh connection.


Usually "invoke" means "start running" What do you mean by "invoke"?


>>
>> I am writing a python script that needs this functionality.
>>
>> What I've come up with (that doesn't work) is:
>>
>> ssh -i ~/ssh/backup_key user@140.203.3.143 "nohup python /home/user/
>> longProcess.py &"
>>
>>
>> This allows me to ssh to the remote machine without a password, but
>> the ssh connection doesn't break until the "longProcess.py" is
>> finished.
>>
>> Hopefully somebody can give me a hint here.
>>
>> Thanks!


ssh user@140.203.3.143 screen -d -m python /home/user/longProcess.py

>Why not simply take the '&' off the end?

Reply With Quote
  #4  
Old 10-25-2008, 11:13 AM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: Use ssh command to *invoke* long running process on remote machine.

In article
<6472a3f4-97c2-4d5b-a19e-01e232125f1e@u75g2000hsf.googlegroups.com>
sophie_newbie writes:
>
>What I've come up with (that doesn't work) is:
>
>ssh -i ~/ssh/backup_key user@140.203.3.143 "nohup python /home/user/
>longProcess.py &"
>
>
>This allows me to ssh to the remote machine without a password, but
>the ssh connection doesn't break until the "longProcess.py" is
>finished.


ssh -i ~/ssh/backup_key user@140.203.3.143 "nohup python \
/home/user/longProcess.py /dev/null 2>&1 &"

(In case your remote shell is [t]csh, use ">& /dev/null" instead of
">/dev/null 2>&1".) This is probably in a FAQ somewhere - ssh(d) is
waiting for your process to finish in case it wants to do some (I/)O
that you want to catch - if its stdin/out/err is redirected away from
the connection (actual files instead of /dev/null works fine too), there
is nothing to wait for.

--Per Hedeland
per@hedeland.org
Reply With Quote
  #5  
Old 10-25-2008, 04:45 PM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: Use ssh command to *invoke* long running process on remotemachine.

Doesn't seem to make a difference...

On Oct 24, 8:04*pm, Nico Kadel-Garcia wrote:
> sophie_newbie wrote:
> > Hi all,

>
> > I'm wondering if I can use the ssh command in Ubuntu to invoke a long
> > running process on a remote machine and when the process has been
> > invoked to break the ssh connection.

>
> > I am writing a python script that needs this functionality.

>
> > What I've come up with (that doesn't work) is:

>
> > ssh -i ~/ssh/backup_key u...@140.203.3.143 "nohup python /home/user/
> > longProcess.py &"

>
> > This allows me to ssh to the remote machine without a password, but
> > the ssh connection doesn't break until the "longProcess.py" is
> > finished.

>
> > Hopefully somebody can give me a hint here.

>
> > Thanks!

>
> Why not simply take the '&' off the end?


Reply With Quote
  #6  
Old 10-28-2008, 10:59 AM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: Use ssh command to *invoke* long running process on remotemachine.

On Oct 25, 11:13*am, p...@hedeland.org (Per Hedeland) wrote:
> In article
> <6472a3f4-97c2-4d5b-a19e-01e232125...@u75g2000hsf.googlegroups.com>
>
> sophie_newbie writes:
>
> >What I've come up with (that doesn't work) is:

>
> >ssh -i ~/ssh/backup_key u...@140.203.3.143 "nohup python /home/user/
> >longProcess.py &"

>
> >This allows me to ssh to the remote machine without a password, but
> >the ssh connection doesn't break until the "longProcess.py" is
> >finished.

>
> ssh -i ~/ssh/backup_key u...@140.203.3.143 "nohup python \
> * /home/user/longProcess.py /dev/null 2>&1 &"
>
> (In case your remote shell is [t]csh, use ">& /dev/null" instead of
> ">/dev/null 2>&1".) This is probably in a FAQ somewhere - ssh(d) is
> waiting for your process to finish in case it wants to do some (I/)O
> that you want to catch - if its stdin/out/err is redirected away from
> the connection (actual files instead of /dev/null works fine too), there
> is nothing to wait for.
>
> --Per Hedeland
> p...@hedeland.org


Thats great seems to do the job.
Reply With Quote
Reply

Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can get process id of a process running on remote machine. unix Unix 2 11-23-2007 06:25 AM
Schedule long running process unix Weblogic 0 10-10-2007 05:19 AM
Schedule long running process unix Weblogic 0 10-10-2007 12:05 AM
how to invoke a series of long running commands in the background and at a low priority _clb_ unix Windows NT 1 10-01-2007 10:20 PM
how to invoke a series of long running commands in the background and at a low priority _clb_ unix Windows NT 1 10-01-2007 08:42 PM


All times are GMT. The time now is 09:44 PM.