LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to keep running program after SSH logout without screen (http://www.linuxquestions.org/questions/linux-software-2/how-to-keep-running-program-after-ssh-logout-without-screen-4175435487/)

gigam 11-03-2012 02:07 PM

How to keep running program after SSH logout without screen
 
Hello everyone.
I am logged into a computer through ssh. I would like to run a program and have it keep running after I log out without screen (i forgot to run it).

For example:
ssh server
user/comp~$ top &
[1] 12021
exit

after that:
ssh server
user/comp~$ (something, maybe shell script) 12021

How can I do that except disown solution?

acid_kewpie 11-03-2012 03:39 PM

you forgot to run screen? why not just run it now?? that is the perfect solution, and I'm not aware of anything else that would be suitable.

archShade 11-03-2012 03:53 PM

check out nercshttp://caca.zoy.org/wiki/neercs

acid_kewpie 11-03-2012 04:22 PM

Hmm, not sure how "screen + pointless gimmicks" is going to be better than just using screen.

archShade 11-03-2012 04:40 PM

From linked website emphasis mine
Quote:

neercs is a work-in-progress libcaca project.

Like GNU screen, it allows you to detach a session from a terminal, but provides unique features:
  • Grabbing a process that you forgot to start inside neercs
  • Great screensaver
  • 3D rotating cube to switch between full screen terms
  • Real time thumbnails of your shells
  • Special effects when closing a window
  • Various window layouts...

Yes there are ways to do this with screen but they all seem to be a bit of a hack.

I agree all the other stuff seems just to be a good way burn cpu cycles

gigam 11-03-2012 04:46 PM

Quote:

Originally Posted by acid_kewpie (Post 4821570)
you forgot to run screen? why not just run it now?? that is the perfect solution, and I'm not aware of anything else that would be suitable.

It's a hack-task: I have a process, and i need to detach it from a tty1 and attach to my recent tty2. Or relogin to ssh service and attach it in my current session and continue working with it.

Quote:

Grabbing a process that you forgot to start inside neercs
Yeah, that's it! But it's a custom solution, it's not solution by OS environment.
And the problem is: how to do that without external applications?

acid_kewpie 11-03-2012 04:48 PM

Heh, well that neercs program does actually say it can grab an existing process, so maybe I look a bit silly now...

gigam 11-03-2012 04:58 PM

Quote:

Originally Posted by acid_kewpie (Post 4821602)
Heh, well that neercs program does actually say it can grab an existing process, so maybe I look a bit silly now...

Well, I have an example of solution, but it has it's own drawbacks:

Code:

#!/usr/bin/bash
while [ true ]
do
sleep 1
echo "I'm alive"
done

Code:

ps aux|grep deatachme.sh|grep -v grep| awk '{print $2 }'
tty 
ls -l /proc/$PID/fd //output process's file descriptors
touch stdout
touch stderr
gdb -p $PID

in gdb:


Code:

p close(1) //close stdout
p open("/home/user/stdout", 1)
p close(2) //close stderr
p open("/home/user/stderr", 2)
q //quit


in the terminal with living process: Ctrl+Z

Code:

bg %1 && disown %1

ctrl+d
echo "hello" > /proc/$PID/fd/0


larvel 11-03-2012 05:54 PM

What about "nohup command"?

gigam 11-03-2012 06:13 PM

Quote:

Originally Posted by larvel (Post 4821639)
What about "nohup command"?

You need to use nohup before command is running.
This solution contradicts to the terms of the problem.

gigam 11-04-2012 06:39 AM

Quote:

Originally Posted by archShade (Post 4821595)
From linked website emphasis mine
Yes there are ways to do this with screen but they all seem to be a bit of a hack.

Well, tell me, please, about theese ways :)


All times are GMT -5. The time now is 01:49 AM.