Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-13-2012
Registered User
 
Join Date: Oct 2011
Posts: 42
Thanks: 33
Thanked 1 Time in 1 Post
Can I convert a foreground process to NOHUP ?

OS : AIX 6.1/Solaris 10

After I started running a shell script, I've realized that it will take another 5 hours to complete. Is there anyway I could convert this foreground process to run in nohup mode so that I can go home peacefully ?

I have the process ID


Code:
$ ps -ef | grep myschellscript_process
  nbkp_usr 3461298       1   0 17:17:54      -  1:03 myschellscript_process

Sponsored Links
    #2  
Old 07-14-2012
Registered User
 
Join Date: May 2005
Posts: 286
Thanks: 1
Thanked 20 Times in 20 Posts
Usually ctrl-Z is mapped to susp in stty for a terminal.. so pressing that suspends the running foreground job and it gets a job number... then you can can use the "bg" command to background it. HOWEVER... if the foreground process is tied to tty input... it will block on i/o... so not everything can be successfully backgrounded... I don't see that problem in your case though.
Sponsored Links
    #3  
Old 07-14-2012
alister alister is offline Forum Advisor  
Registered User
 
Join Date: Dec 2009
Posts: 2,601
Thanks: 123
Thanked 717 Times in 600 Posts
Quote:
Originally Posted by cjcox View Post
Usually ctrl-Z is mapped to susp in stty for a terminal.. so pressing that suspends the running foreground job and it gets a job number... then you can can use the "bg" command to background it. HOWEVER... if the foreground process is tied to tty input... it will block on i/o... so not everything can be successfully backgrounded... I don't see that problem in your case though.
Putting a job in the background doesn't modify its signal mask and make it immune to SIGHUP.

Regards,
Alister

---------- Post updated at 11:29 PM ---------- Previous update was at 11:27 PM ----------

I just realized that you responded to a month-old thread. I hope the original poster got some sleep that night.

Regards,
Alister
    #4  
Old 07-15-2012
ɹǝsn sıɹɐlos
 
Join Date: Dec 2007
Location: Paris
Posts: 4,143
Thanks: 14
Thanked 400 Times in 368 Posts
On Solaris 10 at least, you can use the nohup command afterwards nohup -p pid to prevent the running process to die when you leave your shell and to get its output in a file (nohup.out).
The Following 2 Users Say Thank You to jlliagre For This Useful Post:
alister (07-15-2012), methyl (07-15-2012)
Sponsored Links
    #5  
Old 07-15-2012
alister alister is offline Forum Advisor  
Registered User
 
Join Date: Dec 2009
Posts: 2,601
Thanks: 123
Thanked 717 Times in 600 Posts
Quote:
Originally Posted by jlliagre View Post
On Solaris 10 at least, you can use the nohup command afterwards nohup -p pid to prevent the running process to die when you leave your shell and to get its output in a file (nohup.out).
I wasn't aware that any systems provided such an interface. Thanks.

Looks like AIX supports it as well.
nohup Command

Hopefully the OP consulted his man pages soon after posting.

Regards,
Alister

---------- Post updated at 10:37 AM ---------- Previous update was at 09:06 AM ----------

If the script was started with bash or ksh93 (perhaps other shells as well), the disown built-in can be used. This ensures that the interactive shell won't send SIGHUP to that job's process group if its controlling terminal is closed (which is usually the source of a SIGHUP). Note that this does not modify any process' signal mask, so if a SIGHUP arrives from somewhere, the process will be terminated.

Regards,
Alister
The Following User Says Thank You to alister For This Useful Post:
methyl (07-15-2012)
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How can put a background process to the foreground tomlee Shell Programming and Scripting 3 03-02-2011 11:26 PM
what is the diff b/w background and foreground process onequestion UNIX for Advanced & Expert Users 5 02-24-2010 02:07 AM
Bringing a nohup process to foreground mbguy UNIX for Advanced & Expert Users 3 05-25-2009 07:18 AM
bringing a process to the foreground JamieMurry UNIX for Dummies Questions & Answers 1 04-12-2009 10:54 AM
Background and Foreground of a process within a script ctruhn Shell Programming and Scripting 2 10-06-2008 09:34 AM



All times are GMT -4. The time now is 06:45 AM.