pid of nohup process


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting pid of nohup process
# 1  
Old 10-17-2007
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:

Code:
nohup /start/script.ksh 1>/dev/null 2>&1
print $$ > .pid

nohup /start/script2.ksh 1>/dev/null 2>&1
print $$ >> .pid

But in the .pid file I get the pid of the script that contains the nohup statements instead of the pid of the nohup statement, what I would expect.
# 2  
Old 10-23-2007
$$ gives you the pid of the current shell that is why it is giving you the pid of the script or session that is calling the nohup statement. you need to place the print $$ within script.ksh and script2.ksh or you will have to get the pid list of the child processes of the current shell. I'll try to paste that part once I figure it out ... but for now see if it is feasible to place those commands within script.ksh and script2.ksh.


hope this helps,
Vj
# 3  
Old 10-23-2007
got it ....
$! gives the child pid .....

Code:
nohup /start/script.ksh 1>/dev/null 2>&1
print $! > .pid

nohup /start/script2.ksh 1>/dev/null 2>&1
print $! >> .pid


Vj

Last edited by radoulov; 08-30-2011 at 11:28 AM.. Reason: Code tags.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Kill nohup process with changing PID

Hi there! I have a tricky problem concerning a nohup process: I started a python2.7 script which loops over a function. At the end it restarts the function. Due to a mistake I'm now having a never ending nohup process that I have to kill. I started the program execution with: >>nohup... (4 Replies)
Discussion started by: Lydia
4 Replies

2. 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

3. Shell Programming and Scripting

Help with finding the exit status of a 'nohup' command using 'PID'.

Hello All, I need to run a set of scripts, say 50 of them, parallely. I'm running these 50 scripts, from inside a script with the help of 'nohup' command. 1.The fifty scripts are stored in a separate file. 2.In a master script, i'm reading every line of the file through loop and executing... (4 Replies)
Discussion started by: SriRamKrish
4 Replies

4. Shell Programming and Scripting

I need to save a pid of a child started with $: su <user> -c “nohup …”

Hello, I want to save pid of a child process but I get empty file. su myuser -c "nohup ./mydaemon.sh >/dev/null 2>&1 & print $! > mydaemon.pid" This one works: nohup ./mydaemon.sh >/dev/null 2>&1 & print $! > mydaemon.pid Please help. Thank you in advance. (2 Replies)
Discussion started by: vincegata
2 Replies

5. Shell Programming and Scripting

Storing process Id of a nohup command

Hi, I am running below code: for i in `ls` do nohup sqlldr userid=apps/apps data=data01.dat log=my1.log control=my.ctl bad=my1.bad direct=yes silent=all parallel=true & done This will run the sqlldr command in parallel as a background process. I want to store the process Id each... (7 Replies)
Discussion started by: Pratiksha Mehra
7 Replies

6. UNIX for Dummies Questions & Answers

Process status for NOHUP command

Hi, I have run a shell script as a background process using 'nohup' command. I want to see the process id of this, so that I will be able to kill it later on when required. I tried to collect these details using 'ps' command and could not view this information. How do we get this... (5 Replies)
Discussion started by: Dev_Dev
5 Replies

7. Shell Programming and Scripting

output nohup file containg the PID

Hi to everybody. Is it possible to nohup a process and redirect the output to a file containing the PID? E.g. if nohup filename > out.nohup associate the PID=8074 to filename, is it possible to call the output file something like out_8074.nohup instead of out.nohup? By this way it would... (0 Replies)
Discussion started by: plsrn
0 Replies

8. 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

9. UNIX for Dummies Questions & Answers

Need to get pid of a process and have to store the pid in a variable

Hi, I need to get the pid of a process and have to store the pid in a variable and i want to use this value(pid) of the variable for some process. Please can anyone tell me how to get the pid of a process and store it in a variable. please help me on this. Thanks in advance, Amudha (7 Replies)
Discussion started by: samudha
7 Replies

10. Shell Programming and Scripting

nohup process hangs

Hi All, I tried searching for this, but I have yet to find anything useful. So here goes, if a script executed from another script with nohup & hangs, does it affect the parent script? Reason I ask, we have a windows box with NFS, and we use it to store some of our files. Currently, I mount the... (2 Replies)
Discussion started by: Sully
2 Replies
Login or Register to Ask a Question