Sponsored Content
Full Discussion: Kill PID with one liner
Top Forums Shell Programming and Scripting Kill PID with one liner Post 302875729 by EAGL€ on Wednesday 20th of November 2013 08:18:42 AM
Old 11-20-2013
Quote:
Originally Posted by RudiC
Why do you need pargs when ps -f does a full listing of process arguments? Try
Code:
ps -ef | nawk '/java/ && $1 ~ /testuser/ && /tomcat.*\/conf\/.*properties/ {print $2}'

Once you're happy with the result, you can kill $(...above...) .
Hello Rudic,

but this part
Code:
/tomcat.*\/conf\/.*properties/

comes with the pargs command output not directly with "ps -ef" output. so I need to apply pargs command to see arguments and if the arguments contains
Code:
/tomcat.*\/conf\/.*properties/

afterwards i can be sure that tomcat process ID is correct so can be killed..

I have checked again;

the following gives arguments of desired PID. I keep the PID in sprintf so that i will use it again as i have to call it again (in Kill -15). I could not complete after the following one, any help appreciated.
Code:
pargs $(ps -ef | nawk '/java/ && !/grep/ && $1~/ericsson/{PID = sprintf("%d",$2);print PID}')


Last edited by EAGL€; 11-21-2013 at 10:33 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

pass pid to kill using script

Hi there, i wonder if anyone can help is there any way that i can write a script that will kill all current ftp processes, for example if ps -ef | grep ftp produces 3 active proceses, then I would like to somehow extract the PID for each one and pass that to kill -9 has anybody done this... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

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

3. Shell Programming and Scripting

getting Ambiguous error on kill -9 @pid from csh

Hello all i have simple script that executing program every 10 seconds im invoke this script as daemon with second script that put it in the background this is my first script (IsAliveTester.csh) #!/bin/csh -f @ iSleep = 10 set processName = "ClientTester" while(1) $processName ... (0 Replies)
Discussion started by: umen
0 Replies

4. UNIX for Advanced & Expert Users

KILL without PID

Hellow Experts i have one problem. i run one script in backgroun. and i want to kill that script with only script name..... so what's the solution.. for your info my script name is "testscript" n it contains "sleep 100" thanks.... (16 Replies)
Discussion started by: luckypower
16 Replies

5. Shell Programming and Scripting

When kill [pid] does not work...

Hi, On my Linux machine, using Bash, I sometimes run into a situation where doing the following does not seem to work at all. kermit@fastbox ~ $ ps -A | grep firefox-bin 5375 ? 00:06:57 firefox-bin <defunct> 5624 ? 00:00:00 firefox-bin kermit@fastbox ~ $ kill 5624... (7 Replies)
Discussion started by: kermit
7 Replies

6. AIX

kill -3 <PID> ... where the output file goes?

Hi all, I am generating the coredump of my JBoss, and by default it puts it in to a particular directory. i.e. JBOSS_HOME/. I would like this output file to be created, lets say in /tmp/dump/. I tried the following: kill -3 9404940>/tmp/dump/out.txt But it created... (3 Replies)
Discussion started by: haroon_a
3 Replies

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

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

9. Shell Programming and Scripting

Kill a PID using script

Hi, I wrote a script to kill a process id. I am able to kill the PID only if I enter the root password in the middle of the execution because I did not run as root i.e after i run the script from the terminal, instead of killing directly, it is killing only after entering the pass when it... (12 Replies)
Discussion started by: rajkumarme_1
12 Replies

10. AIX

Kill pid

I created a program to kill long running pid processes. I am getting the following error message: -f command cannot be found. I also want to count the number of pids that are killed and append the results to a text file. I am new to shell script programming. 1.The first part of code... (10 Replies)
Discussion started by: dellanicholson
10 Replies
pargs(1)                                                           User Commands                                                          pargs(1)

NAME
pargs - print process arguments, environment variables, or auxiliary vector SYNOPSIS
pargs [-aceFlx] [pid | core] ... DESCRIPTION
The pargs utility examines a target process or process core file and prints arguments, environment variables and values, or the process auxiliary vector. pargs outputs unprintable characters as escaped octal in the format xxx, unless the character is one of the characters specified in the "Escape Sequences" section of formats(5), in which case the character is printed as specified in that section. pargs attempts to be sensitive to the locale of the target process. If the target process and the pargs process do not share a common char- acter encoding, pargs attempts to employ the iconv(3C) facility to generate a printable version of the extracted strings. In the event that such a conversion is impossible, strings are displayed as 7-bit ASCII. OPTIONS
The following options are supported: -a Prints process arguments as contained in argv[] (default). -c Treats strings in the target process as though they were encoded in 7-bit ASCII, regardless of the locale of the target. The use of iconv(3C) is suppressed. -e Prints process environment variables and values as pointed at by the _environ symbol or by pr_envp in /proc/pid/psinfo. -F Force. Grabs the target process even if another process has control. -l Displays the arguments as a single command line. The command line is printed in a manner suitable for interpretation by /bin/sh. If the arguments contain unprintable characters, or if the target process is in a different locale, a warning message is dis- played. The resulting command line may not be interpreted correctly by /bin/sh. -x Prints process auxiliary vector. OPERANDS
The following operands are supported: pid Process ID list. core Process core file. EXIT STATUS
The following exit values are returned: 0 Successful operation. non-zero An error has occurred (such as no such process, permission denied, or invalid option). FILES
/proc/pid/* Process information and control files. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWesu | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
proc(1), iconv(3C), proc(4), ascii(5), attributes(5), environ(5), formats(5) SunOS 5.10 13 Apr 2004 pargs(1)
All times are GMT -4. The time now is 03:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy