LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to reactivate process sent to background (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-reactivate-process-sent-to-background-387280/)

zeb_666 11-28-2005 11:23 AM

How to reactivate process sent to background
 
Hi!

I am currently running lots of software on my Linux RedHat 8.0 server, among those is a Half-Life Server.

Now, when I start this server I type nohup in front of the name so that it won't shut down when I log off the SSH client, I don't know if nohup is needed but it works fine. Anyway, when I log back into the machine, of course the server is running in the background, vissible in "top" but not in PS, my question is:

Can I reactivate the process in some way so that I can type commands to the server from SSH without having to restart it, eneter the commands, and then send it to the background ?

Please advise,

Sebastian Andersson

EclipseAgent 11-28-2005 11:45 AM

fg

MensaWater 11-28-2005 11:47 AM

If you'd backgrounded it with bg you could use fg to foreground it. That's typically within the same terminal though. Since you logged out there's no guarantee you're on the same terminal (unless you're on the console or a serial terminal). You can do "man bash" for more details of fg if you want to try.

A way to do this though is to use the "screen" command. This is designed to allow you to start something making it independent of where you're logged in so that when you log out it is still running (good for things that do output to your terminal that don't like being backgrounded normally). You can later login on another terminal and access the screen that was previously started. I used this quite a bit up until about a year ago - haven't had much need recently.

Some of my notes about usage of "screen":

screen -list - Shows screen session names
screen -S <name> - Starts screen session and gives it <name> as name.
screen -x <pid> - Attaches to existing screen session with PID of <pid>.
screen -x <name> - Attaches to existing screen session named <name>.(This doesn't always work)
Ctrl-A - Main command to use within screen. Selected options:
Ctrl-A ? - Gives a list of all options
Ctrl-A 0 - Goes to first window within a screen session.
Ctrl-A 1 - Goes to second window within a screen session.
Ctrl-A <n> - Goes to nth window within a screen session.
Doing exit from within a screen session will fall back to previous window.
Doing exit from all windows in screen session will terminate screen.
Closing window that has a screen session will leave it running and detached.

zeb_666 11-28-2005 12:45 PM

Thanks for the reply, Ill try it first thing tomorrow!


All times are GMT -5. The time now is 04:38 AM.