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.
When I start a process and then send it to bg using Ctrl+Z, it is stopped, right? To resume I use the bg command, right?
Imagine I'm in a remote ssh session, I start a process and want to send it to bg so that I can logout and leave the process running. How can I do that? And how can I see the results when I login again?
check out 'rpmfind.net' a valuable resource for any rpm based distro.
screen, just as background, works as a 'virtual shell', i guess. You run screen, it opens up a new shell and continues running that shell until you explicity kill it. You can jump into or out of that shell at any time.
Putting an ampersand -&- behind any command makes it immediately go into the background. However, if the command wants to write to it's controlling terminal then it will simply stop until you bring it to the foreground again. Using 'nohup' will let it continue in the background in the absence of a controlling terminal and will also prevent it from exiting when it gets the 'HUP' signal when you log out.
If the command doesn't need to print anything to the terminal then it may just continue to run in the bakground even after you log out without the nohup command; it all depends on what the program does when it receives a 'HUP' signal. Some programs ignore it, some quit.
It depends on the process. When you logout, all processes are sent a HUP signal, but it's up to the process to decide what to do with it. Some exit, some continue running. Most daemon-type processes simply reload their configuration settings when they receive a HUP.
Also, if you background a process and leave it running on one terminal, you can't bring it forward on another unless you were using the 'screen' app mentioned earlier.
I hope my post is as relevant to this thread as I feel it is..
I'm having much the same problem/situation since I also want to get a process running in the background..
I have an Openvpn-process that I've tried to startup as an backgroundprocess.
I want to be able to start it via remote ssh and then logout again.
I've tried to execute the original command with it's required options and then ended it with an ampersand. Although, this command requires input of login & passwd after execution, but when I end the command with an "&" it simply skips this login/passwd part and then the process doesn't start up properly..
If I simply start it by it's usuall command I can't exit the shell and logout since when I do a Ctrl+C it shuts down the process..
Hopefully someone else's been through this who could help me out..
If the issue you're having is just not getting a password prompt when you attempt to run the command, there's this nice little property about sudo... it sticks around. If you have to put in a sudo password for a command, your next several sudo commands don't need a password. So just before you run the command, do something like
sudo ls
and that gets you your sudo, you run the sudo nohup [command] & and you're good to go.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.