remote job execution via xterm

remote job execution via xterm

am 04.09.2005 04:37:04 von Karthik Vishwanath

Hello,

In order to run some (standard C) code on several machines, I log into a
machine remotely (via ssh), run the executable, hit Ctrl-Z (in the xterm),
and set the job into the background with bg (All of this is done from a an
xterm running bash, locally, and getting a bash shell on the remote
machines as well; all machines involved were running one or another
flavor of Linux.)

The trouble is that when I log out of the remote machine (via CTRL-D) I do
not return to the local prompt on the xterm. I get no display and no
response to any key strokes (including CTRL-C etc.) If close the xterm
window (from within X, locally) the job on the remote machines gets
terminated. The only way to ensure that the remote job stays alive is by
ssh'ing into the remote machine and killing a lone ssh PID that spawned
the executable.

A sample session output is pasted below:
-----------
[karthik @mithrandir ~]$ ssh karthikv@edinburgh

[karthikv @edinburgh Dumps]$ ./trmc_2fls_core RTV-POPOP-tissue2.tissue >
RTV-POPOP-tissue2.out (CTRL-Z)
[1]+ Stopped ./trmc_2fls_core RTV-POPOP-tissue2.tissue
>RTV-POPOP-tissue2.out

[karthikv @edinburgh Dumps]$ bg
[1]+ ./trmc_2fls_core RTV-POPOP-tissue2.tissue >RTV-POPOP-tissue2.out &

[karthikv @edinburgh Dumps]$ pstree -ap karthikv
sshd,8548
`-bash,8549
|-pstree,8620 -ap karthikv
`-trmc_2fls_core,8619 RTV-POPOP-tissue2.tissue

--------> after a CTRL-D here, the terminal is hung as mentioned earlier.
From a new xterm then, again:

[karthik @mithrandir ~]$ ssh karthikv@edinburgh

[karthikv @edinburgh Dumps]$ pstree -ap karthikv
sshd,8548

sshd,8679
`-bash,8680
`-pstree,8710 -ap karthikv

trmc_2fls_core,8619 RTV-POPOP-tissue2.tissue

---------> here a kill -9 8548 keeps the job (8619) alive and brings the
original xterm back to the local prompt.


What is going on? How can I ensure that ssh terminates and disconnects
from the session without me having to do all of the above and making sure
that the executable stays alive?


Thanks and regards,

-K

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: remote job execution via xterm

am 04.09.2005 05:50:21 von Bryan

Karthik Vishwanath wrote:

>Hello,
>
>In order to run some (standard C) code on several machines, I log into a
>machine remotely (via ssh), run the executable, hit Ctrl-Z (in the xterm),
>and set the job into the background with bg (All of this is done from a an
>xterm running bash, locally, and getting a bash shell on the remote
>machines as well; all machines involved were running one or another
>flavor of Linux.)
>
>The trouble is that when I log out of the remote machine (via CTRL-D) I do
>not return to the local prompt on the xterm. I get no display and no
>response to any key strokes (including CTRL-C etc.) If close the xterm
>window (from within X, locally) the job on the remote machines gets
>terminated. The only way to ensure that the remote job stays alive is by
>ssh'ing into the remote machine and killing a lone ssh PID that spawned
>the executable.
>
>A sample session output is pasted below:
>-----------
>[karthik @mithrandir ~]$ ssh karthikv@edinburgh
>
>[karthikv @edinburgh Dumps]$ ./trmc_2fls_core RTV-POPOP-tissue2.tissue >
>RTV-POPOP-tissue2.out (CTRL-Z)
>[1]+ Stopped ./trmc_2fls_core RTV-POPOP-tissue2.tissue
>
>
>>RTV-POPOP-tissue2.out
>>
>>
>
>[karthikv @edinburgh Dumps]$ bg
>[1]+ ./trmc_2fls_core RTV-POPOP-tissue2.tissue >RTV-POPOP-tissue2.out &
>
>[karthikv @edinburgh Dumps]$ pstree -ap karthikv
>sshd,8548
> `-bash,8549
> |-pstree,8620 -ap karthikv
> `-trmc_2fls_core,8619 RTV-POPOP-tissue2.tissue
>
>--------> after a CTRL-D here, the terminal is hung as mentioned earlier.
>>From a new xterm then, again:
>
>[karthik @mithrandir ~]$ ssh karthikv@edinburgh
>
>[karthikv @edinburgh Dumps]$ pstree -ap karthikv
>sshd,8548
>
>sshd,8679
> `-bash,8680
> `-pstree,8710 -ap karthikv
>
>trmc_2fls_core,8619 RTV-POPOP-tissue2.tissue
>
>---------> here a kill -9 8548 keeps the job (8619) alive and brings the
>original xterm back to the local prompt.
>
>
>What is going on? How can I ensure that ssh terminates and disconnects
>from the session without me having to do all of the above and making sure
>that the executable stays alive?
>
>
>Thanks and regards,
>
>-K
>
>-
>To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at http://www.linux-learn.org/faqs
>
>
>
Hello,

I think it is possible you are leaving this process in your job list.
Bash has a way of keeping track of all your jobs. Type "jobs" at the
command prompt and you will see this list. When you log off, every job
gets a hangup signal which kills the job.

You can take a process out of your job list with the disown command.
That way, it won't get the hangup signal when you log off.

There are other ways to do this, but here is what I think you should do:

$ ./your_program &
$ disown
$ logout

For more information, you can do man bash and search for "disown",
"jobs", "bg", and "fg".

Best Regards,
Bryan H.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: remote job execution via xterm

am 04.09.2005 15:51:00 von Tobias Hirning

--nextPart2028851.Muu98Aks4b
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi,
On Sunday, 4. September 2005 04:37 Karthik Vishwanath wrote:
> [...]
> What is going on? How can I ensure that ssh terminates and
> disconnects from the session without me having to do all of the
> above and making sure that the executable stays alive?
You can use nohup.

nohup ./your_program &

The ouput of the program will be written to nohup.log
Tobias
=2D-=20
GPG-Fingerprint: C39E 5381 7721 8613 B5C9 CFAF 54FC B8DB D02D 7085
Registered Linux-User #367044
Registered Linux-Machine #262062
http://counter.li.org
Diese E-Mail wurde mit einer fortgeschrittenen elektronischen
Signatur nach §2 2. d) SigG signiert.

--nextPart2028851.Muu98Aks4b
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQBDGvvuVPy429AtcIURAgZBAJ0fYCyL68Ao/m+7LeRZDfqR1y41ZgCd EWV9
+/AoPqOInasmsfm9/0lQ0yw=
=5o2c
-----END PGP SIGNATURE-----

--nextPart2028851.Muu98Aks4b--
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs