LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-03-2012, 02:07 PM   #1
gigam
LQ Newbie
 
Registered: Aug 2012
Posts: 9

Rep: Reputation: Disabled
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?

Last edited by gigam; 11-03-2012 at 02:48 PM.
 
Old 11-03-2012, 03:39 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
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.
 
Old 11-03-2012, 03:53 PM   #3
archShade
Member
 
Registered: Mar 2006
Location: Delft NL
Distribution: Debian; Slackware; windows 7
Posts: 218

Rep: Reputation: 53
check out nercshttp://caca.zoy.org/wiki/neercs
 
Old 11-03-2012, 04:22 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
Hmm, not sure how "screen + pointless gimmicks" is going to be better than just using screen.
 
Old 11-03-2012, 04:40 PM   #5
archShade
Member
 
Registered: Mar 2006
Location: Delft NL
Distribution: Debian; Slackware; windows 7
Posts: 218

Rep: Reputation: 53
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
 
Old 11-03-2012, 04:46 PM   #6
gigam
LQ Newbie
 
Registered: Aug 2012
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by acid_kewpie View Post
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?

Last edited by gigam; 11-03-2012 at 04:50 PM.
 
Old 11-03-2012, 04:48 PM   #7
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
Heh, well that neercs program does actually say it can grab an existing process, so maybe I look a bit silly now...
 
Old 11-03-2012, 04:58 PM   #8
gigam
LQ Newbie
 
Registered: Aug 2012
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by acid_kewpie View Post
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

Last edited by gigam; 11-03-2012 at 05:07 PM.
 
Old 11-03-2012, 05:54 PM   #9
larvel
LQ Newbie
 
Registered: Jun 2012
Posts: 29

Rep: Reputation: Disabled
What about "nohup command"?
 
Old 11-03-2012, 06:13 PM   #10
gigam
LQ Newbie
 
Registered: Aug 2012
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by larvel View Post
What about "nohup command"?
You need to use nohup before command is running.
This solution contradicts to the terms of the problem.
 
Old 11-04-2012, 06:39 AM   #11
gigam
LQ Newbie
 
Registered: Aug 2012
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by archShade View Post
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
 
  


Reply

Tags
gdb, linux, processes, session, stdin


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running a program on SSH login beskone Linux - General 2 10-26-2008 12:05 PM
ssh-ing into an already running program everyday Linux - Software 4 07-23-2008 04:08 AM
HELP!! running program to ssh bad_jaye Linux - Newbie 4 02-25-2008 07:23 PM
program running after logout? ygloo Linux - General 12 10-10-2006 01:23 AM
Running Program Through SSH windisch Linux - General 6 10-04-2005 06:10 AM


All times are GMT -5. The time now is 01:51 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration