Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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
Code:
mozilla &
then you can close the xterm(or whatever terminal window you have open) and the app will continue to run.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.