Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 09-29-2005, 07:32 PM   #1
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, 03:47 AM   #2
LQ Guru
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 68
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:
And then launch your app:
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!

Old 10-24-2005, 02:55 AM   #3
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.

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

Rep: Reputation: 31
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.

Old 10-24-2005, 08:15 AM   #5
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, 01:17 PM   #6
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,



"Uniting to restore our Constituion"


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

All times are GMT -5. The time now is 07:35 PM.

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