Download your favorite Linux distribution at LQ ISO.
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 06-08-2003, 01:47 AM   #1
Registered: Jan 2003
Location: Dallas, TX
Distribution: Fedora Core 4
Posts: 420

Rep: Reputation: 30
Very Easy One

How do you run a program in the background? I would like to run a Roger Wilco base station service without having to keep the shell open, but I don't want it opened by a startup script when the computer boots. How would I go about this? I want to have a general idea so I can do it in the future rather than an answer to this specific case. Thanks a bunch.
Old 06-08-2003, 02:00 AM   #2
Registered: Oct 2002
Location: East Point, GA
Posts: 188

Rep: Reputation: 30
umm.... do you mean run a program in the background from the command line? just put a '&' after the command. like if i wanted to start like mozilla i would type
mozilla &
then you can close the xterm(or whatever terminal window you have open) and the app will continue to run.

Last edited by padlamoij; 06-08-2003 at 02:04 AM.
Old 06-08-2003, 02:03 AM   #3
Registered: May 2002
Location: Ohio
Distribution: Mandrake 9.2 Custom Kernel & Mythtv!
Posts: 256

Rep: Reputation: 30
yes, as padlamoij said that would work fine.
You can also add a short cut to your start menu.
Depending on your desktop gui there are various ways to do this.
Old 06-08-2003, 02:27 AM   #4
LQ Newbie
Registered: Jun 2003
Location: Campbell, CA, US
Distribution: Debian
Posts: 2

Rep: Reputation: 0
In the simplest case you can simply append an & (ampersand) to the command. This is the same as running it, typing [Ctrl]-[z], then the bg (shell job control: "background") command.

This will run the command in the background. However, it may stop on its own (from a signal that it gets regarding the terminal focus SIGTTOU I believe). For instance vi has nothing useful to do in the background and thus will immediately restop if you try run it in the background. A program that's designed to run in the background will not suffer from this problem; of course.

You can invoke a program with stdin, stdout, and stderr all redirected to /dev/null to isolate a program from your terminal.

Another issue you might run into with some programs will occur if or when you exit the shell from which you started the program. In this case the backgrounded program will still get the "hangup" signal from the shell exiting (or the xterm or other terminal connection to that shell being closed). In other words, it's more signal handling stuff. The default signal handler for SIGHUP is to die. Obviously a program that installs a handler for that can continue to run in the background even after its parent program has died.

You can run the nohup utility to force a program to run even through a hangup signal. Read the nohup man page for details on that. In general you can also run the disown built-in (shell command) to remove a program from the job control and signal dispatches by the shell.

It's even possible to run a program under screen and force that screen session to start up detached. This connects the program to a psuedo-terminal in such a way that you can always re-attached to it later (to see its output and any error messages, and to provide it with terminal inputs).

That's an advanced technique I won't go into here.

Of course programs that are designed to run as daemons can (and should) do their down work, setting themselves up their own "session/process group" --- detaching themselves from the signal propagation of their parent; closing their "standard" file descriptors, etc. In other words, check the documentation for the program in question to see if it as a command line switch to do the job for you.

Old 06-08-2003, 02:31 AM   #5
Registered: Oct 2002
Location: East Point, GA
Posts: 188

Rep: Reputation: 30
um ya... what he said.
Old 06-08-2003, 02:53 AM   #6
Registered: May 2002
Location: Ohio
Distribution: Mandrake 9.2 Custom Kernel & Mythtv!
Posts: 256

Rep: Reputation: 30

I think Jim went a little too deep for most of us.


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
easy connect not easy in suse greg collins Linux - Newbie 11 03-30-2006 08:31 PM
Easy urpmi ,no easy send mail. akihandyman Linux - General 2 12-27-2004 03:15 PM
Linux4RegularGuys - EASY FTP setup using vsftpd - READ THIS FOR EASY HELP DropHit Linux - Networking 4 11-25-2004 03:44 PM
Easy for most ... Please help.... kaz4u2dig Linux - Newbie 1 10-18-2004 10:46 PM
Here's an easy one... jhotchkiss Linux - Software 5 09-23-2003 12:53 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:28 AM.

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