Sponsored Content
Full Discussion: Nohup and wait command usage
Top Forums Shell Programming and Scripting Nohup and wait command usage Post 303025876 by manid on Wednesday 14th of November 2018 08:37:08 AM
Old 11-14-2018
Code:
while read list
do

nohup ./process.sh $list &

process_id=$!

echo "$prcoess_id" >> process_id.lst

done < sample.lst

while read process_id
do
wait $process_id
done <process_id.lst

command1

command 2


will this work?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Wait Command

Does anyone have an example of a korn shell scripts kicking of multiple background processes and then using the wait command to get the return code from those processes? I want to write a program that kicks off multiple Oracle procedures and then wait for the return code before I procede.... (1 Reply)
Discussion started by: lesstjm
1 Replies

2. UNIX for Dummies Questions & Answers

nohup usage..

Hi, I want to run the below 3 sql files parallely..I know adding a "&" at the end of the command will make it run in background.But each sql file will take a considerable time to execute so i want to apply "nohup" to this execution. Help me how to use " nohup " to these... echo... (2 Replies)
Discussion started by: charan81
2 Replies

3. Shell Programming and Scripting

wait command - cat it wait for not-chile process?

Did not use 'wait' yet. How I understand by now the wait works only for child processes, started background. Is there any other way to watch completion of any, not related process (at least, a process, owned by the same user?) I need to start a background process, witch will be waiting... (2 Replies)
Discussion started by: alex_5161
2 Replies

4. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

5. Shell Programming and Scripting

wait command

Hi all, I have never used the wait command before and want to know how it works. I basically need to run four sqlplus sessions in parallel as background processes and i am spooling the results obtained from the database into files.I need to wait for all the processes to finish and then make... (2 Replies)
Discussion started by: vinoo128
2 Replies

6. Shell Programming and Scripting

Wait command help

Hi, Is there any way to know the child process status as and when it finished. If i write like below nohup sh a1.sh & ### has sleep 20 ;echo a1.sh nohup sh a2.sh & ### has sleep 10 ;echo a2.sh nohup sh a3.sh & ### has sleep 5 ;echo a3.sh wait This will wait till a1.sh ,a2.sh a3.sh... (0 Replies)
Discussion started by: patrickk
0 Replies

7. Shell Programming and Scripting

Usage of NOHUP - How to keep the child process running even if I close the Server connection

Hi. ! When I use the 'NOHUP' along with the '&', the process will be running in the background. Even when I attempt to close (Meaning 'EXIT') the session (say PUTTY in this case), it wont exit unless the process is completed. But, say when I forcefully terminate the session (SHUT DOWN the... (2 Replies)
Discussion started by: WinBarani
2 Replies

8. UNIX for Dummies Questions & Answers

Command to display the space usage (memory usage) of a specific directory.

Hi all, Can you please tell me the command, with which one can know the amount of space a specific directory has used. df -k . ---> Displays, the amount of space allocated, and used for a directory. du -k <dir name> - gives me the memory used of all the files inside <dir> But i... (2 Replies)
Discussion started by: abhisheksunkari
2 Replies

9. Shell Programming and Scripting

In Shell Script Does Second Command Wait For First Command To Complete

Hi All, I have a question related to Shell scripting. In my shell script, I have following two commands in sequence: sed 's/^/grep "^120" /g' $ORIGCHARGEDAMTLIST|sed "s;$;| cut -f$FIELD_NO1 -d '|' | awk '{ sum+=\$1} END {printf (\"%0.2f\\\n\", sum/100)}' >$TEMPFILE mv $TEMPFILE $ORIGFILE... (3 Replies)
Discussion started by: angshuman
3 Replies

10. AIX

Wait time shows high CPU usage

Hi, I can't seem to make sense of this. My wait time is showing really high but vmstat's and topas are showing normal usage. ps aux USER PID %CPU %MEM SZ RSS TTY STAT STIME TIME COMMAND root 9961810 5680.7 0.0 448 384 - A Dec 16 6703072:12 wait ... (2 Replies)
Discussion started by: techy1
2 Replies
setpgid(2)							System Calls Manual							setpgid(2)

NAME
setpgid, setpgrp - Sets the process group ID SYNOPSIS
#include <unistd.h> int setpgid( pid_t process_id, pid_t process_group_id); pid_t setpgrp(void); Application developers may want to specify an #include statement for <sys/types.h> before the one for <unistd.h> if programs are being developed for multiple platforms. The additional #include statement is not required on Tru64 UNIX systems or by ISO or X/Open standards, but may be required on other vendors' systems that conform to these standards. The following alternate declaration for setpgrp() does not conform to current standards and is supported only for backward compatibility: int setpgrp( pid_t process_id, pid_t process_group_id); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: setpgid(): XSH5.0 setpgrp(): SVID 3, XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the ID of the process whose process group ID is to be changed. Specifies the new process group ID. DESCRIPTION
Use the setpgid() function to add a process to an existing process group or to create a new process group within a process's session. The setpgid() function does not change the process group ID of a session leader. The setpgid() function sets the process group ID of the process identified by the process_id parameter. The process group ID is set to the value specified in the process_group_id parameter. If the process_id parameter contains 0 (zero), the setpgid() function sets the process group ID of the calling process. The new value of the process group ID is the one specified in the process_group_id parameter. If the process_group_id parameter contains 0 (zero), the setpgid() function sets the process group ID of the specified process using the process group ID of the calling process. The specified process is the one identified by the process_id parameter. The setpgid() function supports job control. The setpgrp() function sets the process group ID of the calling process to be equal to the process ID of the calling process. If the func- tion creates a new session, the new session has no controlling terminal. This function does not change the process group ID of a session leader. NOTES
[Tru64 UNIX] When compiled in the X/Open UNIX environment, calls to the setpgrp() function are internally renamed by prepending _E to the function name. When you are debugging a module that includes the setpgrp() function and for which _XOPEN_SOURCE_EXTENDED has been defined, use _Esetpgrp to refer to the setpgrp() call. See standards(5) for further information. [Tru64 UNIX] The backward-compatible version of the setpgrp() function is supported for use outside of the System V habitat or X/Open- UNIX environment. This version of setpgrp( behaves like the setpgid() function. In this case, you specify a process ID and process group ID as parameters in the call to setpgrp(). The setpgrp() function does not change the process group ID of a session leader. RETURN VALUES
Upon successful completion, the setpgid() function returns a value of 0 (zero). Otherwise, the function returns a value of -1 and sets errno to indicate the error. Upon successful completion, the setpgrp() function returns the new process group ID. [Tru64 UNIX] The alternate version of setpgrp() returns a value of 0 (zero) on successful completion. Otherwise, the function returns a value of -1 and sets errno to indicate the error. ERRORS
The setpgid() function sets errno to the specified values for the following conditions: The value of the process_id parameter matches the process ID of a child process of the calling process and the child process has successfully executed one of the exec() functions. The value of the process_group_id parameter is less than or equal to 0 (zero), or is not a valid process ID. The value of the process_group_id parameter is a valid process ID, but that process is not in the same session as the calling process. The process indicated by the process_id parameter is a session leader. The value of the process_id parameter matches the process ID of a child process of the calling process and the child process is not in the same session as the calling process. The value of the process_group_id parameter is valid but does not match the process ID of the process indicated by the process_id parameter, and there is no process with a process group ID that matches the value of the process_group_id parameter in the same ses- sion as the calling process. The value of the process_id parameter does not match the process ID of the calling process or of a child process of the calling process. No errors are defined for the standard version of the setpgrp() function. [Tru64 UNIX] The backward-compatible version of setpgrp() sets errno to the same values as setpgid(). RELATED INFORMATION
Functions: exec(2), fork(2), getpid(2), getsid(2), kill(2) Standards: standards(5) Guides: Programmer's Guide delim off setpgid(2)
All times are GMT -4. The time now is 12:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy