Script causing multi forked porcess - not sure why ?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Script causing multi forked porcess - not sure why ?
# 1  
Old 12-16-2008
Script causing multi forked porcess - not sure why ?

Hi,

I am facing a queer situation, when i run the below script it starts up multiple forked process and hangs the unix server , we had to reboot the server once. Can someone pls help me understand why the script is causing multiple processes to start . If i run ps -ef rename.sh , after i start it and even cancel it (ctrl+c) still i see numerous multiple processes starting

Script name: rename.sh



#!/bin/sh
(
echo "Script `$basename $0` started at `date`"
echo " "
echo "Merging files A and B at `date`"
## merge 1
merge_files.ksh /dummy/test/files file_list_A*txt N N file_list_A.txt
echo "Status (file_list_A) = $?"
echo " "
merge_files.ksh /dummy/test/files file_list_B*txt N N file_list_B.txt
echo "Status (file_list_B) = $?"
#
echo " "
#
echo "Merging files C and D at `date`"
## Merge 2
merge_files.ksh /dummy/test/files file_list_C*txt Y N file_list_C.txt
echo "Status (file_list_C) = $?"
echo " "
merge_files.ksh /dummy/test/files file_list_D*txt Y N file_list_D.txt
echo "Status (file_list_D) = $?"
echo " "
echo "Merging of files Done at `date`"
echo "-----------------------------------------------------------"
) >> log_file.log




above script when i run seems to go in loops and forks out multiple porcesses quite fast. The embedded script "merge_files.ksh" which actually merges the files is fine as it runs perfectly fine independently with NO issues at all. The embedded merge_files.ksh takes 5 parameters (as can be seen above when calling it) - file dir path, file pattern name, header flag (Y if header is there and N if not), Footer flag (same as header flag, Y and N), final name of then merged file.

can someone pls guie me as to why the above script is going in loops and forking multiple processes ?
# 2  
Old 12-16-2008
Hard to say why without knowing the contents of the script being called within rename ... You could run the rename script with

sh -x rename.sh

to see whats going on during execution, it will not however show inside of the script being called or any functions in place (which i see you have none in the parent script)

What version of unix is this your running ? as under Solaris

ps -ef rename.sh

is an invalid command on my box id need a |grep in there for it to work ....
# 3  
Old 12-16-2008
thx for the quick reply, sorry it was a typo, it shd be ps -ef | grep -c rename.sh , and i could see thousands of such processes,

i did try running in sh -x mode but it would not give any output but just hang and after i press ctrl + c it would take time to come out but i guess would not be properly killed.
i did check the logs and it shows that the script goes in loops and starts multiple processes of itself.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

While loop is causing ssh command to exit from script after first iteration.

I am trying to check multiple server's "uptime" in a loop over "ssh". When I execute multiple ssh commands with hard coded servernames script is executing fine. But when I pass server names using while loop, script is exiting after checking first server's status, why? # serverList... (8 Replies)
Discussion started by: kchinnam
8 Replies

2. Shell Programming and Scripting

How to substract selective values in multi row, multi column file (using awk or sed?)

Hi, I have a problem where I need to make this input: nameRow1a,text1a,text2a,floatValue1a,FloatValue2a,...,floatValue140a nameRow1b,text1b,text2b,floatValue1b,FloatValue2b,...,floatValue140b look like this output: nameRow1a,text1b,text2a,(floatValue1a - floatValue1b),(floatValue2a -... (4 Replies)
Discussion started by: nricardo
4 Replies

3. Shell Programming and Scripting

Awk script problem - Variables Causing Issue

can someone please explain to me what i'm doing wrong with this code: WELT=$(awk '(($1 ~ "^${caag}$") || ($2 ~ "^${caag}$"))' /tmp/Compare.TEXT) when run from the command line, it works. but it seems to be having a problem doing the comparison when variables are involved. i tested from... (1 Reply)
Discussion started by: SkySmart
1 Replies

4. Shell Programming and Scripting

Script causing database corrupt

Hi, Closing the thread (3 Replies)
Discussion started by: dbashyam
3 Replies

5. Programming

getting the return from forked child process to parent in C++

This needs to work on HPUX and Linux. I do a fork and create a child process. During execution of the child process, it is possible child become lost or get killed. That is the reason why I create the child process. However if the child process doesnt get killed, I do want to know the return... (2 Replies)
Discussion started by: usustarr
2 Replies

6. Shell Programming and Scripting

something is causing this script to break early on

I am relatively new at scripting in linux. Most of my scripting knowledge comes from doing batch scripting in windows. Anyway, I have this script I'm trying to write that will install a program called Nagios along with a few other packages. I know it has to be something at the beginning that is... (4 Replies)
Discussion started by: nanite51
4 Replies

7. UNIX for Advanced & Expert Users

commands not working if the executed from forked process

Hi, I have an application where if it runs indivisually could able to execute commands (like system("ls")) and could able to execute tcl script. Same application if started from health monitor process (From health monitor process my application will be forked), it could not execute the... (1 Reply)
Discussion started by: chandrutiptur
1 Replies

8. Programming

getting the return code of forked child process (ftp)

Hi, From within my C++ program, I fork a child process and execl an ftp session (solaris), like this : std::string szStartCmd = "ftp -i -n -v 192.168.149.31"; int nExecRes = execl("/bin/sh", "sh", "-c", szStartCmd.c_str(), (char *)0); I use 2 pipes to communicate between my... (7 Replies)
Discussion started by: KittyJ
7 Replies

9. Programming

pipe read and write with many forked children

I know how to read and write if i have a forked process with only one child. However what is involved with reading and writing with many forked processes. Say one parent that forks 5 children, and needs to communicate with all 5 in half duplex. int temp, counter=0; do{ pipe(temp); ... (5 Replies)
Discussion started by: steveneliuk
5 Replies

10. Shell Programming and Scripting

Some env setting is causing the script not to work ?

Not sure what has changed in the Unix environment. The following script which was working is now not working. #!/usr/bin/ksh # ----------------------------------------------------------------------------- # File: monitor_db.sh # #... (1 Reply)
Discussion started by: uuser
1 Replies
Login or Register to Ask a Question