How to kill a process and its childs given pid and userid


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to kill a process and its childs given pid and userid
# 1  
Old 06-05-2006
How to kill a process and its childs given pid and userid

I need to write a shell script which would take 2 arguments pid , userid. Then it should kill all the child process under it. If a child process is not killed then it should wait for 1 minute and should kill.

can anybody give me the idea to write it?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to report file size, pid and also kill the process

Hi All, Looking for a quick LINUX shell script which can continuously monitors the flle size, report the process which is creating a file greater than certain limit and also kill that process. Can someone please help me on this? (4 Replies)
Discussion started by: vasavimacherla
4 Replies

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

3. Shell Programming and Scripting

Find the Pid and Kill the Process after a Few Minutes

hi guys i had written a shell script Display Information of all the File Systems i want to find the pid and kill the process after few minutes.how can i obtain the pid and kill it??? sample.sh df -a >> /tmp/size.log and my cron to execute every minute every hour every day * *... (5 Replies)
Discussion started by: azherkn3
5 Replies

4. Red Hat

How to Force KILL State -D Process/PID?

Hi Expert, I am not able to kill certain user process as root. I have tried using: pkill -u uname skill KILL -u uname kill -9 PID *** I have not using killall yet, since this server has more than 100 users online atm. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND... (1 Reply)
Discussion started by: regmaster
1 Replies

5. Shell Programming and Scripting

How to Kill process with dynamic PID?

Hello, I have problem with killing red5 process running on linux server. As this process is continuously changing its PID so it can't be killed with "kill -9 PID" command. First I used following command to list RED5 process ps aux | grep red5 which showed me root 5832 0.0 0.0 4820 756pts/0... (4 Replies)
Discussion started by: ninadgac
4 Replies

6. UNIX for Dummies Questions & Answers

How to Kill process with dynamic PID?

Hello, I have problem with killing red5 process running on linux server. As this process is continuously changing its PID so it can't be killed with "kill -9 PID" command. First I used following command to list RED5 process ps aux | grep red5 which showed me root 5832 0.0 0.0 4820 756pts/0... (1 Reply)
Discussion started by: ninadgac
1 Replies

7. Shell Programming and Scripting

grab PID of a process and kill it in a script

#!/bin/sh who echo "\r" echo Enter the terminal ID of the user in use: echo "\r" read TERM_ID echo "\r" ps -t $TERM_ID | grep sh echo "\r" echo Enter the process number to end: echo "\r" read PID echo "\r" kill -9 $PID What this code does is ultimately grab the PID of a users sh... (6 Replies)
Discussion started by: psytropic
6 Replies

8. Shell Programming and Scripting

KILL PID, intern should kill another PID.

Hi All, In my project i have two process runs in the back end. Once i start my project, and execute the command ps, i get below output: PID TTY TIME CMD 9086 pts/1 0:00 ksh 9241 pts/1 0:02 java 9240 pts/1 0:00 shell_script_bg java with 9241 PID is the main... (4 Replies)
Discussion started by: rkrgarlapati
4 Replies

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

10. UNIX for Dummies Questions & Answers

Script to kill all child process for a given PID

Is there any build in command in unix to kill all the child process for a given process ID ? If any one has script or command, please let me know. Thanks Sanjay (4 Replies)
Discussion started by: sanjay92
4 Replies
Login or Register to Ask a Question
setpgid(2)							System Calls Manual							setpgid(2)

NAME
setpgid(), setpgrp2() - set process group ID for job control SYNOPSIS
DESCRIPTION
The and system calls cause the process specified by pid to join an existing process group or create a new process group within the session of the calling process. The process group ID of the process whose process ID is pid is set to pgid. If pid is zero, the process ID of the calling process is used. If pgid is zero, the process ID of the indicated process is used. The process group ID of a session leader does not change. is provided for backward compatibility only. Security Restrictions Some or all of the actions associated with this system call are subject to compartmental restrictions. See compartments(5) for more information about compartmentalization on systems that support that feature. Compartmental restrictions can be overridden if the process possesses the privilege (COMMALLOWED). Processes owned by the superuser may not have this privilege. Pro- cesses owned by any user may have this privilege, depending on system configuration. See privileges(5) for more information about privileged access on systems that support fine-grained privileges. RETURN VALUE
and return the following values: Successful completion. Failure. is set to indicate the error. ERRORS
If or fails, is set to one of the following values. The value of pid matches the process ID of a child process of the calling process and the child process has successfully executed one of the exec(2) functions. The value of pgid is less than zero or is outside the range of valid process group ID values. The process indicated by pid is a session leader. The value of pid is valid but 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 pgid does not match the process ID of the process indicated by pid and there is no process with a process group ID that matches the value of pgid in the same session as the calling process. The value of pid does not match the process ID of the calling process or of a child process of the calling process. AUTHOR
and were developed by HP and the University of California, Berkeley. SEE ALSO
bsdproc(3C), exec(2), exit(2), fork(2), getpid(2), kill(2), setsid(2), signal(2), privileges(5), termio(7). STANDARDS CONFORMANCE
setpgid(2)