LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 09-29-2005, 08:32 PM   #1
PacMansRancor
LQ Newbie
 
Registered: Sep 2004
Posts: 17

Rep: Reputation: 0
Running as a service


Ok, I have a Linux server I'm using to run a program for my xbox called KLink Kai. I use SSH to start the program and everything works fine, but when I close the SSH it also closes the program. I was wondering if there was a way to make this program run as a service? So I wouldn't have to start it manually and I woulnd't have to leave the SSH open. Thanks
 
Old 09-30-2005, 04:47 AM   #2
MasterC
Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 64
Depends on the program, but if it supports daemonizing, usually the switch is -d, so:
/usr/local/bin/programname -d

May start it as a 'service'. Another option (one that I had to use on occasion and sucks, but works) is to open a screen session:
screen
And then launch your app:
/usr/local/bin/programname
And then detach from the session:
CTRL + ad

Then, once detached, you can leave your ssh session and the program will continue to run in the screen session that you can attach to later with:
screen -r

Good Luck!

Cool
 
Old 10-24-2005, 03:55 AM   #3
aaron123
LQ Newbie
 
Registered: Oct 2005
Posts: 2

Rep: Reputation: 0
Leaving proggie running after closing term window

Another way is to use nohup it. For example:

nohup proggie

Only caveat with this is that in order for nohup to work it has to be able to log to something. By default it will log to terminal but you can redirect it of course. If the program your running generates lots of output you will end up with a big file.

But, you will be able to close the ssh session without it terming the proggie.

Hope it helps,

- Aaron


--------------------

Uniting to restore Constitutional law.

http://TheRevCo.org

Last edited by aaron123; 10-24-2005 at 03:56 AM.
 
Old 10-24-2005, 09:02 AM   #4
Fritz_Monroe
Member
 
Registered: Nov 2004
Location: Maryland, USA
Distribution: Mint 13
Posts: 272

Rep: Reputation: 30
Since nohup needs to log to something, could you redirect it to null?

Just curious since I've got an app that I'm attempting to get to run as a service.

TIA
F_M
 
Old 10-24-2005, 09:15 AM   #5
GaMeS
Member
 
Registered: Jan 2005
Location: France / Bretagne
Distribution: Debian / Gentoo
Posts: 71

Rep: Reputation: 15
you can use

/path/of/programme &

the '&' key backgrounding process
 
Old 10-24-2005, 02:17 PM   #6
aaron123
LQ Newbie
 
Registered: Oct 2005
Posts: 2

Rep: Reputation: 0
backgrounding doesnt give it immunity from closing session

Backgrounding the proggie doesnt give it immunity from closing the session.

You can redirect it to null, but I believe you have to be using stderr, like so:

nohup /usr/lib/proggie 2> /dev/null

So yea, nohuping it will keep it open after you close your ssh window/session, and stderr redirecting it to null prevents a file from growing.

Hope that works for you,

Aaron

-------------------------------------------------------------

"Uniting to restore our Constituion"

http://TheRevCo.org
 
  


Reply


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
way to check and see if a service is running nephish Linux - Software 10 02-11-2006 04:36 PM
How can I tell if a particular service (eth0) is running or not? donJulio Slackware 4 09-21-2005 02:37 AM
Running a service as a user Jake_da_Snake Linux - Security 1 06-17-2005 05:22 PM
script to check if the service is running eyt Linux - Newbie 2 02-16-2004 08:27 AM
Running a service at startup correro Linux - General 14 02-18-2003 08:00 PM


All times are GMT -5. The time now is 06:36 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration