Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Manipulate o/p of a Linux command Post 303045630 by MadeInGermany on Saturday 4th of April 2020 03:52:52 PM
Old 04-04-2020
It is
Code:
pgrep -l rpm | while read pid cmd
...

or better
Code:
pgrep -x rpm | while read pid
...

Even better is to check for the elapsed time
Code:
ps -e -o pid= -o etime= -o fname= |
while read pid etime cmd
do
  if [ "$cmd" = "rpm" ]
  then
    case $etime in ( *-* )
      kill "$pid"
    ;;
    esac
  fi
done

The *-* matches anything with a dash; this is true if the process is more than one day old. So it will fix your emergency, but leave enough rpm processes running to remind you to do a root cause analysis plus a proper fix.
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Manipulate files

Hi everybody: I have a problem. I have a output files which have this pattern: number1 --space block1a - 7rows/10columns/65elements --space block1b - 7rows/10columns/65elements --space block1c - 7rows/10columns/65elements --space number2 --space block2a - 7rows/10columns/65elements... (0 Replies)
Discussion started by: tonet
0 Replies

2. Shell Programming and Scripting

Sed command to find, manipulate and replace a number

Hi, Im very new to the world of sed so I'm really not even sure if this is possible. What i need to do is read from a flat file and every time i see this line: VAL=123,456 I need to change 456 to 457 for every occurence of this line in the file. The numbers 123 and 456 are different for... (6 Replies)
Discussion started by: LT_2008
6 Replies

3. Shell Programming and Scripting

manipulate & format the output of spool command

Hi All, I am spooling the data some sql queries into a single file but wanted to know how to format the data of the file generated by spool. #!/bin/sh unset -f USAGE USAGE () { clear echo "############################USAGE#######################\n" echo "Incorrect number of... (2 Replies)
Discussion started by: ss_ss
2 Replies

4. Programming

Manipulate the Linux ARP Cache in C

Hello, I need help on how to "access" or manipulate the Linux ARP Cache in C, here is the description of the project i'm working in: There are a lot of tools that analize ARP frames and send an e-mail to the sysadmin, that's easy. What i want to do is to inspect every ARP frame that arrives... (18 Replies)
Discussion started by: semash!
18 Replies

5. Shell Programming and Scripting

awk command to manipulate csv file in UNIX

Hi, I am new to awk/unix and am trying to put together a script to manipulate the date column in a csv file. I have file1.csv with the following contents: Date,ID,Number,Amount,Volume,Size 01-Apr-2014,WERFG,998,105873.96,10873.96,1342.11 01-Apr-2014,POYFR,267,5681.44,5681.44,462.96 I... (2 Replies)
Discussion started by: Prit Siv
2 Replies

6. Shell Programming and Scripting

awk command to manipulate csv file in UNIX

Hi, I am new to awk and unix programming and trying to manipulate a csv file. My current csv file looks like this: col1,col2,col3,col4,col5,col4,col5,col6,col7,col8 223,V,c,2,4,f,r,,y,z 223,V,c,3,2,f,r,,y,z 223,V,c,1,4,f,r,,y,z 223,V,c,4,3,f,r,,y,z 227,V,c,3,1,f,r,,y,z... (8 Replies)
Discussion started by: Prit Siv
8 Replies

7. UNIX for Beginners Questions & Answers

Simple sed command not working; could be a Mac/Linux vs. PC/Linux issue

Hello, I am on a Mac and trying to clean up some monthly files with a very simple SED: sed '3,10d;/<ACROSS>/,$d' input.txt > output.txt (from the input, delete lines 3 - 10; then delete from the line containing <ACROSS> to the end of the file) then output to output.txt Even when I try... (2 Replies)
Discussion started by: verbatim
2 Replies
KILL(1) 							Linux User's Manual							   KILL(1)

NAME
kill - send a signal to a process SYNOPSIS
kill [ -signal | -s signal ] pid ... kill [ -L | -V, --version ] kill -l [ signal ] DESCRIPTION
The default signal for kill is TERM. Use -l or -L to list available signals. Particularly useful signals include HUP, INT, KILL, STOP, CONT, and 0. Alternate signals may be specified in three ways: -9 -SIGKILL -KILL. Negative PID values may be used to choose whole process groups; see the PGID column in ps command output. A PID of -1 is special; it indicates all processes except the kill process itself and init. SIGNALS
The signals listed below may be available for use with kill. When known constant, numbers and default behavior are shown. Name Num Action Description 0 0 n/a exit code indicates if a signal may be sent ALRM 14 exit HUP 1 exit INT 2 exit KILL 9 exit cannot be blocked PIPE 13 exit POLL exit PROF exit TERM 15 exit USR1 exit USR2 exit VTALRM exit STKFLT exit might not be implemented PWR ignore might exit on some systems WINCH ignore CHLD ignore URG ignore TSTP stop might interact with the shell TTIN stop might interact with the shell TTOU stop might interact with the shell STOP stop cannot be blocked CONT restart continue if stopped, otherwise ignore ABRT 6 core FPE 8 core ILL 4 core QUIT 3 core SEGV 11 core TRAP 5 core SYS core might not be implemented EMT core might not be implemented BUS core core dump might fail XCPU core core dump might fail XFSZ core core dump might fail NOTES
Your shell (command line interpreter) may have a built-in kill command. You may need to run the command described here as /bin/kill to solve the conflict. EXAMPLES
kill -9 -1 Kill all processes you can kill. kill -l 11 Translate number 11 into a signal name. kill -L List the available signal choices in a nice table. kill 123 543 2341 3453 Send the default signal, SIGTERM, to all those processes. SEE ALSO
pkill(1), skill(1), kill(2), renice(1), nice(1), signal(7), killall(1). STANDARDS
This command meets appropriate standards. The -L flag is Linux-specific. AUTHOR
Albert Cahalan <albert@users.sf.net> wrote kill in 1999 to replace a bsdutils one that was not standards compliant. The util-linux one might also work correctly. Please send bug reports to <procps-feedback@lists.sf.net> Linux November 21, 1999 KILL(1)
All times are GMT -4. The time now is 06:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy