make a foreground running process to run background without hang up

Tags
advanced, background, foreground, job control, make, nohup

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 08-28-2008
make a foreground running process to run background without hang up

I've tried this a long time ago and was successful but could not remember how i did it. Tried ctrl+Z and then used bg %

could not figure what i did after to keep it no hangup -

not sure if used nohup -p pid, can u plz help me out if this can be done.

Any help will be appreciated.
# 2  
Old 08-28-2008
To place a foreground process in the background: suspend the foreground process (with Ctrl-z) then enter the bg command to move the process into the background.

Show the status of all background and suspended jobs: jobs
Bring a job back into the foreground: fg %jobnumber
Bring a job back into the background: bg %jobnumber

Regards
# 3  
Old 08-28-2008
Depends on the shell whether bg jobs will receive a HUP when you log out; I believe with bash they will not.
# 4  
Old 08-28-2008
i'm working on a korn shell, but my script is running on bash mode, will it affect ?
# 5  
Old 08-29-2008
nohup

You can run your command with `nohup' - this will cause it to ignore all input and send its stdout (and stderr?) to the file "nohup.out" in your cwd. After you've run your command, you can background it as normal (^Z bg) but it will continue to run after you sever the terminal connection.

Depending on your shell (bash for sure, others maybe) you can also use the "disown" command on a job to disconnect it from the controlling terminal.
# 6  
Old 08-30-2008
When you have already started the job you can use "nohup <pid>" to unattach it from the terminal you are on (this is the reason why processes stop when you log off - they are attached to a terminal and this terminal ceases to exist when you log off) so they won't stop when you log off.

Therefore:

Code:
$ job                    # starts the job
$ <CTRL-Z>               # stops the job
$ bg                     # puts the job in background
$ nohup <PID>            # unattaches the backgrounded job from the terminal

I hope this helps.

bakunin
# 7  
Old 08-30-2008
I had never heard of nohup PID and it does not seem to be supported by GNU coreutils nohup, so I guess it's not portable. But if it works for you, good.
Login to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Similar Threads More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Running process in the background uniran UNIX for Beginners Questions & Answers 4 04-11-2018 03:33 AM
Make background process interact with fg process ashima jain Shell Programming and Scripting 0 10-14-2015 04:52 AM
Process remians in Running state causing other similar process to sleep and results to system hang naveeng UNIX for Advanced & Expert Users 6 10-08-2015 12:31 PM
Process remians in Running state causing other similar process to sleep and results to system hang naveeng UNIX for Advanced & Expert Users 1 10-07-2015 07:20 AM
Process remians in Running state causing other similar process to sleep and results to system hang naveeng BSD 0 10-07-2015 07:19 AM
How to run Background process one after another Navrattan Bansa Shell Programming and Scripting 5 02-02-2012 01:28 AM
command to see process running at background nks342 Shell Programming and Scripting 1 11-08-2011 04:47 AM
How can put a background process to the foreground tomlee Shell Programming and Scripting 3 03-03-2011 12:26 AM
what is the diff b/w background and foreground process onequestion UNIX for Advanced & Expert Users 5 02-24-2010 03:07 AM
How to process and run a program in the background in perl? vanitham Shell Programming and Scripting 0 02-04-2010 03:14 AM
send a new value to a variable in a running background process razziel UNIX for Advanced & Expert Users 2 04-22-2009 11:57 AM
Background and Foreground of a process within a script ctruhn Shell Programming and Scripting 2 10-06-2008 10:34 AM
how to make a parent wait on a child shells running in background? albertashish UNIX for Advanced & Expert Users 1 08-01-2008 02:13 PM
How to know the status of process running in background sumanta Shell Programming and Scripting 8 03-04-2008 05:03 AM
running process in background kingdbag UNIX for Dummies Questions & Answers 3 11-10-2006 12:34 PM
All times are GMT -4. The time now is 11:29 AM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.