LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-21-2005, 07:52 PM   #1
ziggo0
LQ Newbie
 
Registered: Aug 2004
Location: La Porte, Indiana
Distribution: Slackware 10
Posts: 11

Rep: Reputation: 0
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
 
Old 02-21-2005, 08:07 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
http://wiki.linuxquestions.org/wiki/Nohup
 
Old 02-21-2005, 08:24 PM   #3
ziggo0
LQ Newbie
 
Registered: Aug 2004
Location: La Porte, Indiana
Distribution: Slackware 10
Posts: 11

Original Poster
Rep: Reputation: 0
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?
 
Old 02-21-2005, 08:52 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
In theory.
 
Old 03-05-2005, 01:30 PM   #5
Bitwaba
LQ Newbie
 
Registered: Mar 2005
Posts: 1

Rep: Reputation: 0
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
 
  


Reply



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 Program Through SSH windisch Linux - General 6 10-04-2005 06:10 AM
Keeping a program running between SSH sessions ark86 Linux - Newbie 2 10-01-2005 03:31 PM
running a program in background of X using & Dachy Linux - General 1 09-13-2005 11:38 AM
running rsync from a background c program BassJunkie Programming 2 08-26-2005 05:38 AM
Program In background frankprogramer Linux - Software 1 10-30-2002 02:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:21 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration