I am trying to kill PIDs that are tied to a KSH "load_sqlplus" and I am using the below code
The issue i am facing is there are child processes that are tied to PIDs that falls in the above category and
those are not getting killed.
In other words when i execute the above script I also want to kill any child PIDs associated with the PIDs
getting killed..
Any input will be greatly appreciated
I would be very careful about killing processes that are banging up against a database. Some will argue that you should attempt to kill any process with a TERM or HUP signal before resorting to 'kill -9' as it gives the process a chance to finish gracefully.
That said, if you decide that you still want to kill all of the processes, and any descendants of those processes, that match a pattern, you might have to resort to something like the script below. There might be some 'pstree-like' command out there that does it, but if I knew of one it escapes me at the moment.
The script accepts a pattern to search the output from ps for (be careful, you could easily over match) and lists all of the PIDs that match, and the descendents; one group per line. It tries to be smart about not listing itself or related processes; your milage might vary on whether it is successful at that or not. It should be easy to extend this to actually issue the kill commands, but I'll stay away from posting any such code.
Please post what Operating System and version you have and what Shell you are using. Not all have "pgrep", "ptree" or "pkill".
Never ever issue "kill -9" to a process which might be connected to a database. The only exception I know is when you need to forcibly shut down a database where sessions are stuck on I/O (e.g. after a disc failure).
In your case "kill -15" has a good chance of killing the child processes too.
The "kill -9" could easily leave the child process parentless and looping.
Depending on the circumstances it is usually better to use database tools to disconnect a client rather than crashing the process.
HI i would like to know how i can simulate a shell scripts for my requirement.
example
Server name child Process id Parent Process id
Vpesh 16013 15637
Server name child Process id Parent Process id
Vpesh 16014 15637
Server name child... (1 Reply)
Hi everyone
i am very new to linux , working on bash shell.
I am trying to solve the given problem
1. Create a process and then create children using fork
2. Check the Status of the application for successful running.
3. Kill all the process(threads) except parent and first child... (2 Replies)
Hi friends,
I have a small question regarding unix system call fork, I hope you will solve my problem. Here is the small program
$ cat fork1.c
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main()
{
int pid;
int x = 0;
x = x + 1;
pid = fork();
if(pid < 0)
{... (2 Replies)
Hello,
I am trying to create a pipe that will direct stdout to in side of the pipe, and stdin to the out side of the pipe - I created two child processes to handle this. However, my pipe doesn't seem to be working correctly. Did I use execv() correctly? Command1 and command2 represent the two... (3 Replies)
Consider this simple command line
bash -c 'echo $$ ; sleep 10000'This will print the newly created bash PID and sleep for a long time.
If I go to another terminal and do something like
ps -flax | grep leepI'll see something like
501 92418 91910 0 0:00.00 ttys000 0:00.00 bash -c echo $$... (5 Replies)
Hi,
I am writing korn shell script. My requirement is, i have to kill the parent process and all of its child processes. Can some one please help me on this?
Thanks in advance for your help.. (1 Reply)
Hi
I am trying to see if there are some options in ps command or if there is a shell script which basically shows you all the processes spawned by a parent process , then all the processes of its child processes and so on down the hierarchy may be like a tree structure. It might be a generic... (6 Replies)
Hello.
I have a global function name func1() that I am sourcing in from script A. I call the function from script B. Is there a way to find out which script called func1() dynamically so that the func1() can report it in the event there are errors?
Thanks (2 Replies)
Hello all,
I have gone through the search and looked at posting about idle users and killing processes. Here is my question I would like to kill an idle user ( which I can do) but how can I asure that all of his process is also killed whit out tracing his inital start PID. I have tried this on a... (4 Replies)
I don't follow what these are...
this is what my text says...
"When a process is started, a duplicate of that process is created. This new process is called the child and the process that created it is called the parent. The child process then replaces the copy for the code the parent... (1 Reply)