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 ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Use ssh command to *invoke* long running process on remote machine.

  1. 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!

  2. 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?

  3. 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?


  4. 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

  5. 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?



  6. 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 to Thread