LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Running a program in the background - SSH (https://www.linuxquestions.org/questions/linux-newbie-8/running-a-program-in-the-background-ssh-293199/)

ziggo0 02-21-2005 07:52 PM

Running a program in the background - SSH
 
How can i run a program in the background if im connected to a comptuer through SSH? I know i can use the command say './hlds_run &' and it will start in the background, but when i disconnect my session the terminal closes and the program closes. I only have access to the homedir of my account. So all in a nutshell is there a command i can use to run the program in the background even after ive closed the terminal? Thanks for everyones replys

michaelk 02-21-2005 08:07 PM

http://wiki.linuxquestions.org/wiki/Nohup

ziggo0 02-21-2005 08:24 PM

Thank you very much :)

So i started the command in /home/x7hus/hlds/ since the program 'hlds_run' is in there. I used the following to launch the program for the first time
Code:

nohup ./hlds_run -console -game cstrike -secure -port 27015 +ip 67.19.135.182 +maxplayers 16 +map de_dust2
Once i CTRL + C'ed the terminal the server died. So i ran it with the following '&' at the end, to put it in the background

Code:

nohup ./hlds_run -console -game cstrike -secure -port 27015 +ip 67.19.135.182 +maxplayers 16 +map de_dust2 &
Now it should stay open until the server its self dies or something?

michaelk 02-21-2005 08:52 PM

In theory. :)

Bitwaba 03-05-2005 01:30 PM

Screen
 
Theres also a really cool program called Screen that allows you to run the program in a console that you can attach and detach.

So basicly you start up your screen with something along the lines of :
screen <flags> <screen name> <program>
( i cant remember my exact start up line, its burried in a startup script on another computer).

Then you can detach the screen using "Ctrl+a" then "d".

now you can exit your session, and any time you want to connect to check it out, you can ssh back in and do:
screen -r <screen name>

Head over to :
http://server.counter-strike.net/for...ghlight=screen

for a little more information.

__
Bitwaba


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