Sponsored Content
Top Forums Shell Programming and Scripting Killing the Wrong Background Process Post 302348710 by Vi-Curious on Saturday 29th of August 2009 09:03:44 AM
Old 08-29-2009
You could modify what you have to use pkill instead of kill so that you can kill a process by name rather than pid and pass it certain attributes (like user id or terminal id) to restrict which process it kills.

----------------------------------------------

If you continue to call it the way you are now, if you extract the PPID when calling ps, you can pkill with process name and PPID.

Last edited by Vi-Curious; 08-29-2009 at 10:15 AM.. Reason: Add PPID info
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

killing a process pid

What option is used with kill to cause the server to reread its config file. (16 Replies)
Discussion started by: jo calamine
16 Replies

2. UNIX for Dummies Questions & Answers

killing a process

I can kill running processes on my linux red hat system using ctrl-c but cannot do it from command line of another terminal using kill -2 pid. Although I can kill them from command line using kill -9 pid and other signals. I would like to do it using the kill -2 pid. Thanks for your suggestions (6 Replies)
Discussion started by: bbhayana
6 Replies

3. Shell Programming and Scripting

Killing of a process and send a mail if the process doesnot come up within 2 minutes

Hi Friends, I am new to this forum as well as new to shell scripting. I have a problem here and i need someone to solve this. Let us consider there are two processes(abc & def).There is a script which kills these two processes(i.e killtheprocess abc). Here abc is the argument . There is a... (1 Reply)
Discussion started by: Prince89
1 Replies

4. UNIX for Dummies Questions & Answers

killing the process

Hi, First, I am running a scipt.While the script is running I realize that I dont want the script to be run so I am killing the script externally.Before the process gets terminated or killed it should delete all the temporary files created by the script.How to do this?Can anyone help me? ... (3 Replies)
Discussion started by: arthi
3 Replies

5. Shell Programming and Scripting

Killing process!!!!

Hi friends, i m in big trouble.... i have one script which connects two server ...like below.. script1.sh ------------------------------------- bash test.sh & eval x=$@ export x=`echo $x` #echo $x # ssh user@8.2.5.6 bash /mbbv/location/script.sh $x|sed '/Binary file/d'... (1 Reply)
Discussion started by: Shahul
1 Replies

6. Shell Programming and Scripting

Finding the age of a unix process, killing old processes, killing zombie processes

I had issues with processes locking up. This script checks for processes and kills them if they are older than a certain time. Its uses some functions you'll need to define or remove, like slog() which I use for logging, and is_running() which checks if this script is already running so you can... (0 Replies)
Discussion started by: sukerman
0 Replies

7. UNIX for Dummies Questions & Answers

Script to start background process and then kill process

What I need to learn is how to use a script that launches background processes, and then kills those processes as needed. The script successfully launches the script. But how do I check to see if the job exists before I kill it? I know my problem is mostly failure to understand parameter... (4 Replies)
Discussion started by: holocene
4 Replies

8. Shell Programming and Scripting

How to put FTP process as a background process/job in perl?

Hi, I am using net::ftp for transferring files now i am trying in the same Linux server as a result ftp is very fast but if the server is other location (remote) then the file transferred will be time consuming. So i want try putting FTP part as a background process. I am unaware how to do... (5 Replies)
Discussion started by: vanitham
5 Replies

9. Shell Programming and Scripting

Killing the process ID's

Hi , I have a list of application process id's. Is there a way to kill all the process listed below using the script, except the once which are starting with " Genesis " adm 1522 ABC_Process.tra adm 1939 Genesis_Process.tra adm 2729 Genesis_Archive.tra adm 3259 xyz_Process.tra (5 Replies)
Discussion started by: murali1687
5 Replies

10. Shell Programming and Scripting

Output when killing a background process

I played a bit around with the Terminal and I observed something. When I start and kill a background process, there is some kind of output. After I invoked the command to start the process the first message " 13063" is directly displayed. However, after killing the process, the second message "+... (3 Replies)
Discussion started by: Chuck Morris
3 Replies
time(1) 						      General Commands Manual							   time(1)

Name
       time - time a command

Syntax
       time command
       /bin/time command

Description
       The  command  lets  the specified command execute and then outputs the amount of elapsed real time, the time spent in the operating system,
       and the time spent in execution of the command.	Times are reported in seconds and are written to standard error.

       If you are using any shell except the C shell, you can give the command as shown on the first line of the Syntax section.  If you are using
       the  C shell, you must use the command's full pathname as shown on the second line of the Syntax section.  If you do not use the full path-
       name, will execute its own built-in command that supplies additional information and uses a different output format.

       The command can be used to cause a command to be timed no matter how much CPU time it takes.  For example:
       % /bin/time cp /etc/rc /usr/bill/rc
	       0.1 real 	0.0 user	 0.0 sys
       % /bin/time nroff sample1 > sample1.nroff
	       3.6 real 	2.4 user	 1.2 sys
       This example indicates that the command used negligible amounts of user and system time and had an elapsed time of 1/10 second (0.1).   The
       command used 2.4 seconds of user time and 1.2 seconds of system time, and required 3.6 seconds of elapsed time.

Restrictions
       Times are measured to an accuracy of 1/10 second.  Thus, the sum of the user and system times can be larger than the elapsed time.

See Also
       csh(1)

																	   time(1)
All times are GMT -4. The time now is 06:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy