Sponsored Content
Top Forums Shell Programming and Scripting Preparing a list of spawned processes Post 302464928 by huskie69 on Friday 22nd of October 2010 03:55:19 AM
Old 10-22-2010
Almost got there! - not quite though - pgrep -P isn't reporting any further child processes...

Code:
>% ptree 7133
6737  /corp_sys/oas/1.0/glliv/middle/oracle/app/product/10.1.2.0.2/application_server
  6738  /corp_sys/oas/1.0/glliv/middle/oracle/app/product/10.1.2.0.2/application_server
    7128  /bin/sh /corp_sys/oas/1.0/glliv/middle/oracle/app/product/10.1.2.0.2/applicatio
      7133  tee -a reports.log
        7134  /corp_sys/oas/1.0/glliv/middle/oracle/app/product/10.1.2.0.2/application_server
          18480 /corp_sys/oas/1.0/glliv/middle/oracle/app/product/10.1.2.0.2/application_server
>% pgrep -P 7133
7134

Should pgrep -P be reporting proc ID 18480 as well?



---------- Post updated 22-10-10 at 08:55 AM ---------- Previous update was 21-10-10 at 02:57 PM ----------




I've managed to get it working (sort of).

Part of the exercise is to kill off the parent process of the problem processes anyway using another script. Therefore, once these have been killed, I'm only left with the proceses from 7133 downwards.

I can now kill them using something like this:

Code:
        rm /tmp/rep_srv_proc.tmp
        rm /tmp/rep_srv_proc.tmp_tmp
        REP1=$(ps -ef | grep report | grep -v grep | awk '{print $2}')
        ptree $REP1 | awk '{print $1}' > /tmp/rep_srv_proc.tmp_tmp
        ptree $REP1 | awk '{print "kill -9 "$1}' > /tmp/rep_srv_proc.tmp
        chmod 777 /tmp/rep_srv_proc.tmp
        clear
        echo "-----------------------------"
        echo "Do you wish to kill the following processes?:" 
        cat /tmp/rep_srv_proc.tmp_tmp
                echo "-----------------------------"
        read answer
            case $answer in
                yes|Yes|Y|y)
                    /tmp/rep_srv_proc.tmp
                    echo "Processes have been killed..."
                    ;;
                no|n|N|NO)
                    clear 
                    echo "-----------------------------"
                    echo "You've chosen not to kill any processes..."
                    exit
                    ;;
                esac

Thanks for the pointer Methyl.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Is there any cmd to kill a process including its childs ( or sub processes spawned by

Dear Unix Gurus, Here is my query. If i start a script,it inturn calls many other scripts ..and most of them continue to run in parallel. Suppose,if i want to stop my script for some reason,i need to kill -9 each of the processes running.It becomes clumsy if the sub processes r more. ... (15 Replies)
Discussion started by: gvsreddy_539
15 Replies

2. Linux

How to receive results from processes spawned on external machines using SSH

I am trying to get the number of cpus on a farm of linux boxes (about 100 of them) by 'sshing' to each of them and checking their /proc/cpuinfo file. So I have a local script localscript.sh on each of those 100 machines which retrieves the number of cpus in it by using its /proc/cpuinfo file.... (1 Reply)
Discussion started by: waavman
1 Replies

3. Programming

how to get list of processes

Hi, How can I get a list of all the running processes, in C? (13 Replies)
Discussion started by: yaron
13 Replies

4. SuSE

List of processes/ which ones to stop

Hi there, I've install a testserver with SLES 11.0! I'll install/test XEN + WebServer not all things at the moment! In a first time, I'd like to stop all unuse processes... but I don't understand all processes! As someone a list of all processes with his signification and which should/could... (3 Replies)
Discussion started by: hiddenshadow
3 Replies

5. Shell Programming and Scripting

Need to list 3 days old processes

ps -xfu <user name> this command line will list all the process currently running for <user name>. I need to filter this output. I need all the process which are running for more than 3 days(excluding demon/sys process) . The list should include PID, PPID, STIME, process/command. I am using... (20 Replies)
Discussion started by: Sriranga
20 Replies

6. UNIX for Dummies Questions & Answers

List processes that are running on other hosts

Hi: How to list processes from all hosts, as opposed to the one you are working at? "ps ux" appears to list processes of the user on a single host only. Thanks. N.B Phil (5 Replies)
Discussion started by: phil518
5 Replies

7. Solaris

Get list of running network processes

Hello All I am trying to get a list of process or applications runninging on the network only. I should emphasize that im not interested in the application or process if its not using the network. I tried the good old netstat comand, but im not able to figure out how to list the running... (8 Replies)
Discussion started by: busi386
8 Replies

8. UNIX for Advanced & Expert Users

Kill a list of processes

I am trying to kill a list of processes. I have found these two ways to list a group of process id's on a single line. How would I go about killing all of these processes all on one line? $ ps aux | grep 6243 | grep "a.out" | awk '{printf "%s ",$2}'ps aux | grep 6243 | grep "a.out" | awk... (8 Replies)
Discussion started by: cokedude
8 Replies

9. UNIX for Advanced & Expert Users

List all background processes

How do I list the process in a Unix based system which are running in background? The following are options that I'm aware of, but they may not be appropiate. a. using ps -ef , and getting records of processes for which STATUS='S'(uninterruptible sleep) b. using jobs -l, and filtering... (5 Replies)
Discussion started by: kumarjt
5 Replies

10. Shell Programming and Scripting

List processes using my memory

Here is the output of top command So you see 99% of memory is in use -> Mem: 66005468k total, 65662548k used, How can I find out all processes consuming this 99% memory in descending order of consumption i.e. starting with processes eating more memory. I need the total of the output to... (3 Replies)
Discussion started by: mohtashims
3 Replies
ptree(1)																  ptree(1)

NAME
ptree - print process trees SYNOPSIS
/usr/bin/ptree [-a] [-c] [-z zone] [pid | user] ... ptree prints the process trees containing the specified pids or users, with child processes indented from their respective parent pro- cesses. An argument of all digits is taken to be a process-id, otherwise it is assumed to be a user login name. The default is all pro- cesses. The following options are supported: -a All. Print all processes, including children of process 0. -c Contracts. Print process contract memberships in addition to parent-child relationships. See process(4). This option implies the -a option. -z zone Zones. Print only processes in the specified zone. Each zone ID can be specified as either a zone name or a numerical zone ID. This option is only useful when executed in the global zone. The following operands are supported: pid Process-id or a list of process-ids. ptree also accepts /proc/nnn as a process-id, so the shell expansion /proc/* can be used to specify all processes in the system. user Username or list of usernames. Processes whose effective user IDs match those given are displayed. Example 1: Using ptree The following example prints the process tree (including children of process 0) for processes which match the command name ssh: $ ptree -a `pgrep ssh` 1 /sbin/init 100909 /usr/lib/ssh/sshd 569150 /usr/lib/ssh/sshd 569157 /usr/lib/ssh/sshd 569159 -ksh 569171 bash 569173 /bin/ksh 569193 bash The following exit values are returned: 0 Successful operation. non-zero An error has occurred. /proc/* process files See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWesu | +-----------------------------+-----------------------------+ |Interface Stability |See below. | +-----------------------------+-----------------------------+ The human readable output is Unstable. The options are Evolving. gcore(1), ldd(1), pargs(1), pgrep(1), pkill(1), plimit(1), pmap(1), preap(1), proc(1), ps(1), ppgsz(1), pwd(1), rlogin(1), time(1), truss(1), wait(1), fcntl(2), fstat(2), setuid(2), dlopen(3C), signal.h(3HEAD), core(4), proc(4), process(4), attributes(5), zones(5) 11 Oct 2005 ptree(1)
All times are GMT -4. The time now is 07:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy