Can I convert a foreground process to NOHUP ?


 
Thread Tools Search this Thread
# 1  
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

# 2  
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.
# 3  
Quote:
Originally Posted by cjcox
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  
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).
These 2 Users Gave Thanks to jlliagre For This Post:
# 5  
Quote:
Originally Posted by jlliagre
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. Smilie

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
This User Gave Thanks to alister For This Post:
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Science: Computers
Difficulty: Medium
All program codes have to be compiled into an executable file in order to be run. This file can then be executed on any machine.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Running process in nohup

Hi All, I am facing issue in running a process in nohup. I ran a process in terminal since it is taking too long to complete I need to make it as background and nohup. I tried below and was able to make it in back ground 1. Cntrl + Z 2. bg I am using Korn Shell so disown is not working... (5 Replies)
Discussion started by: arunkumar_mca
5 Replies

2. Shell Programming and Scripting

How to detect that foreground process is waiting for input?

Hi, I have to create a script (ksh or perl) that starts certain number of parallel jobs (another scripts), each of them runs as a foreground process in a separate session. Plus I start monitoring job that has to determine if any of those scripts is expecting input from operator, and switch to... (4 Replies)
Discussion started by: andyh80
4 Replies

3. Shell Programming and Scripting

How can put a background process to the foreground

Hi, guys: I am working on my own shell using c. When I put a process into the background, how can I put it back to the foreground using tcsetpgrp? Thanks (3 Replies)
Discussion started by: tomlee
3 Replies

4. UNIX for Advanced & Expert Users

what is the diff b/w background and foreground process

What are all the difference between a Background and Foreground processes ?! A Background process does not have access to STDIN and OUT.. What else ? Is there any detailed description available somewhere ? (5 Replies)
Discussion started by: onequestion
5 Replies

5. UNIX for Advanced & Expert Users

Bringing a nohup process to foreground

Hi, I have used nohup command to run a process in background. i ran successfully and i exit from that terminal. But when i login for the next time I am not able to see the process but it is working, since I am getting a e-mail alert for error issue. Please let me know how to bring that process... (3 Replies)
Discussion started by: mbguy
3 Replies

6. UNIX for Dummies Questions & Answers

bringing a process to the foreground

If i have a single file i would just press fg but if i have multiple files running in the backgound and want to bring a specific one to the foreground how would i do that? Thanks!! (1 Reply)
Discussion started by: JamieMurry
1 Replies

7. UNIX for Advanced & Expert Users

nohup and background process

What is the difference between running a process using nohup and running a process in background ? Please explain (6 Replies)
Discussion started by: srksn
6 Replies

8. Shell Programming and Scripting

Background and Foreground of a process within a script

I'm not sure if it is even possible but I figured if it was someone here would know how to do it... I am running a script which starts a bunch of processes in the background but there is one process I would like to bring back to the foreground when complete. Unfortunately the process that I... (2 Replies)
Discussion started by: ctruhn
2 Replies

9. UNIX for Advanced & Expert Users

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. (12 Replies)
Discussion started by: pharos467
12 Replies

10. Shell Programming and Scripting

pid of nohup process

I want to print the pid of a nohup process to a file so later I can use the list of pid's in that file to stop the background processes again. I use ksh on AIXv5.3: nohup /start/script.ksh 1>/dev/null 2>&1 print $$ > .pid nohup /start/script2.ksh 1>/dev/null 2>&1 print $$ >> .pid But... (2 Replies)
Discussion started by: rein
2 Replies

Featured Tech Videos