LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 12-01-2004, 01:37 PM   #1
esasse
LQ Newbie
 
Registered: Nov 2004
Location: Americana, SP - Brazil
Distribution: Fedora
Posts: 17

Rep: Reputation: 0
Put a process in background and logout


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?

Thanks!
 
Old 12-01-2004, 02:04 PM   #2
redgren
Member
 
Registered: Nov 2004
Distribution: Debian,Homebrew
Posts: 54

Rep: Reputation: 15
Not sure if this is exactly what you are looking for, but try the 'screen' command.

After I discovered it, I can't live without it.
 
Old 12-01-2004, 02:39 PM   #3
esasse
LQ Newbie
 
Registered: Nov 2004
Location: Americana, SP - Brazil
Distribution: Fedora
Posts: 17

Original Poster
Rep: Reputation: 0
The "screen" command is not found in my Fedora Core 3 distro and I could not found any references to it. Can you point me?
 
Old 12-01-2004, 02:42 PM   #4
redgren
Member
 
Registered: Nov 2004
Distribution: Debian,Homebrew
Posts: 54

Rep: Reputation: 15
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.
 
Old 12-01-2004, 03:06 PM   #5
Jerre Cope
Member
 
Registered: Oct 2003
Location: Texas (central)
Distribution: ubuntu,Slackware,knoppix
Posts: 323

Rep: Reputation: 37
Another solution would be to use nohup

Ex.

nohup command &

(don't forget the ampersand)

The command will continue when you log out, standard output will go to nohup.out in the directory where you initiated the command.
 
Old 12-01-2004, 03:42 PM   #6
dsegel
Member
 
Registered: Aug 2004
Location: Davis, California
Distribution: Gentoo, always Gentoo.
Posts: 159

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

Last edited by dsegel; 12-01-2004 at 03:44 PM.
 
Old 12-02-2004, 04:36 AM   #7
esasse
LQ Newbie
 
Registered: Nov 2004
Location: Americana, SP - Brazil
Distribution: Fedora
Posts: 17

Original Poster
Rep: Reputation: 0
Ok, so if I forget to use nohup when I started the process I can't logout and leave it running, right?
 
Old 12-02-2004, 09:58 PM   #8
dsegel
Member
 
Registered: Aug 2004
Location: Davis, California
Distribution: Gentoo, always Gentoo.
Posts: 159

Rep: Reputation: 30
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.
 
Old 12-03-2004, 05:37 AM   #9
esasse
LQ Newbie
 
Registered: Nov 2004
Location: Americana, SP - Brazil
Distribution: Fedora
Posts: 17

Original Poster
Rep: Reputation: 0
Ok, thanks!
 
Old 04-15-2011, 05:34 PM   #10
clain
LQ Newbie
 
Registered: Sep 2008
Posts: 1

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


Best Regards
Andreas
 
Old 07-13-2011, 01:44 AM   #11
starfyredragon
LQ Newbie
 
Registered: Jul 2011
Posts: 1

Rep: Reputation: Disabled
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.
 
Old 03-28-2012, 02:53 PM   #12
bclabots
LQ Newbie
 
Registered: Mar 2012
Posts: 1

Rep: Reputation: Disabled
disown

Hi just wanted to add this function to the thread for reference.

#start_whatever_process
[CTRL]+[Z]bg
#disown -h
#exit

Bernard
 
  


Reply



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
Can I put a logout icon on desktop? newtwolinux Linux - Newbie 4 05-17-2005 08:24 PM
running in background hangs on shell logout pfaendtner Linux - Newbie 5 03-25-2005 10:34 AM
how to run any binary in background - background process tej Linux - Newbie 1 08-16-2004 12:27 AM
Does Ctl-Alt-F1 kill X, or just put in background? TreeDragon60 Linux - General 18 03-31-2004 02:17 AM
Background process h8r Linux - Newbie 5 01-13-2003 04:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:19 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
Open Source Consulting | Domain Registration