Automation of "Kill script by name"


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Automation of "Kill script by name"
# 8  
Old 07-12-2012
Quote:
Originally Posted by watashi
Thank you for providing the complete code but I don't quite get how it differs from mine. In my previous code, I made "var" as the pattern to match. Now it seems that you make it a shell script? And then I don't know whether you type in 6361 or it is written in the script. Sorry that I cannot test the code because kill is too damaging and I can't risk killing other users' processes.
You can just copy paste or you can run this in shell script. You just need to change var with your script name.
Below code just prints the kill command. it won't execute it.. You can use exec for executing this command..
Code:
var="jumper_2.sh" 
$ ps -ef | awk -v VD=$var '/VD/{print $2 }' 
6361 
$ echo "kill  `ps -ef | awk -v VD=$var '/VD/{print $2 }'`" 
kill  6361

Tell me what exactly you want to do....
# 9  
Old 07-12-2012
Please don't suggest/use unreliable grep or awk based solutions. Most if not all current Unix / Unix like distributions should provide pgrep and pkill which are much simpler to use and do not exhibit the issues of the former scripts.
# 10  
Old 07-12-2012
Quote:
Originally Posted by jlliagre
Please don't suggest/use unreliable grep or awk based solutions. Most if not all current Unix / Unix like distributions should provide pgrep and pkill which are much simpler to use and do not exhibit the issues of the former scripts.
Hi jlliagre,

Thanks for your advice. I am suggesting what i am using currently........
# 11  
Old 07-12-2012
..... which is unreliable.

The main issues are:

  • They are unnecessarily complex to properly implement
  • Scripts based on grep will often try to kill themselves too, which might pose serious problems depending on the timing.
  • As they are looking to the whole ps output line, they will be quite destructive when provided a pattern that match something else in that line, especially a username, a tty or just a numeric value.
# 12  
Old 07-12-2012
Bug

Quote:
Originally Posted by jlliagre
..... which is unreliable.

The main issues are:

  • They are unnecessarily complex to properly implement
  • Scripts based on grep will often try to kill themselves too, which might pose serious problems depending on the timing.
  • As they are looking to the whole ps output line, they will be quite destructive when provided a pattern that match something else in that line, especially a username, a tty or just a numeric value.
Hi jlliagre,

Thanks for your advice and appreciated your concerns. Could you please guide us for the efficient and optimal way..

Thanks...Smilie
# 13  
Old 07-12-2012
I already did. See post #7.
# 14  
Old 07-12-2012
Thanks a lot...Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. Shell Programming and Scripting

What is the use of "finger" command & how to use it to kill the online processes ?

Hi there, I am eager to know what exactly is the use of "finger" command & how to use it to kill the online processes ? :b: (1 Reply)
Discussion started by: abhijitpaul0212
1 Replies

5. UNIX for Dummies Questions & Answers

"Help with bash script" - "License Server and Patch Updates"

Hi All, I'm completely new to bash scripting and still learning my way through albeit vey slowly. I need to know where to insert my server names', my ip address numbers through out the script alas to no avail. I'm also searching on how to save .sh (bash shell) script properly.... (25 Replies)
Discussion started by: profileuser
25 Replies

6. Shell Programming and Scripting

need to kill a number of processes with name "XYZ" at a time using shell script

Hi, when i grep for the process "XYZ" , there will be some good number of processes with that name, i want to kill all the these processes at a time using shell script? Any help needed for this action. Thanks Regards, Anil (6 Replies)
Discussion started by: anilmanepu
6 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

9. Programming

do you believe X-application will "kill" the CDE and come back to login dialog

1 . Thanks you for reading the letter 2 . I have programe a X-application .Sometimes, I run it from terminal of CDE ,it "kill" the CDE and I meet the login dialog . I debug it . I find that the SIGHUP caused the X-app died .I do not run it from terminal of CDE ,I run it "click button" from panel ,... (3 Replies)
Discussion started by: chenhao_no1
3 Replies
Login or Register to Ask a Question