Remove files with ps -ef |grep


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove files with ps -ef |grep
# 1  
Old 10-28-2011
Remove files with ps -ef |grep

HTML Code:
ps -ef |grep qdaemon |grep /usr/bin/ksh

TOC # 
  d_prod  487630 5034194   0   Oct 27      -  0:00 /usr/bin/ksh /usr/lib/lpd/pio/etc/piojetd umhn-7w36-ps1 9100 -d s /var/spool/qdae
mon/tCVAf7a 
  d_prod 6709402 5034194   0 02:50:19      -  0:00 /usr/bin/ksh /usr/lib/lpd/pio/etc/piojetd 3fens-ps1 9100 -dp /var/spool/qdaemon/t
iL3pUa 
  d_prod 7020672 5034194   0 18:35:03      -  0:00 /usr/bin/ksh /usr/lib/lpd/pio/etc/piojetd 10.5.4.23 9100 -dp /var/spool/qdaemon/t
HL7faa 
  d_prod 7839816 5034194   0   Oct 26      -  0:00 /usr/bin/ksh /usr/lib/lpd/pio/etc/piojetd 10.1.2.28 9100 -d c -p 12 -w 132 -d c -
p 17 -w 182 /var/spool/qdaemon/tx2MiEa 
I want to remove files from
HTML Code:
ps -ef |grep qdaemon |grep /usr/bin/ksh
output if they are older than 24 hours.

Please advise.
# 2  
Old 10-28-2011
Removing the files won't do you any good if those processes are holding them open. You'll want to kill the processes, too.
# 3  
Old 10-28-2011
Ah.. Yes, I meant to kill the PIDs. Thank you for the catch.
Please advise.
# 4  
Old 10-29-2011
Code:
ps -ef |grep qdaemon |grep /usr/bin/ksh | grep -v grep |awk '{print "kill -9 "$2}' | sh

# 5  
Old 10-31-2011
That is great! How do I grep the PIDs that are older than 24 hours? That is what I need in addition to kill -9.

Please advise.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep to remove and add specified characters

I have the following type of 2 column file: motility - role - supplementation - age b ancestry b purity b recommendation b serenity b unease b carving f expansion f I would like to print only certain sections of the file depending on the value of the second column. For instance,... (6 Replies)
Discussion started by: owwow14
6 Replies

2. Shell Programming and Scripting

Grep to remove non-ASCII characters

I have been having an encoding problem that I need to solve. I have an 4-column tab-separated file: I need to remove all of the lines that contain the string 'vis-à-vis' achiever-n vis-à-vis+ns-j+vp oppose-v 1 achiever-n vis-à-vis+ns-the+vg assess-v 1 administrator-n ... (4 Replies)
Discussion started by: owwow14
4 Replies

3. Shell Programming and Scripting

grep to remove blank space

Hi All, Need help to grep blank and copy to file. I have a file in below format dns1dm06_10, dns2dm02_04, dbidub,10000000c9a46d0c gbpuhci,10000000c948b00a ibtur001,10000000c9a1ccda yubkbtp1,10000000c93fec5b I need to copy to all lines which doesn't have wwn >> no-wwn.txt 1... (2 Replies)
Discussion started by: ranjancom2000
2 Replies

4. UNIX for Dummies Questions & Answers

Using grep to remove cells instead of whole lines

I would like to use grep to remove certain strings from a text file but I can't use the grep -v option because it removes the whole line that includes the string whereas I just want to remove the string. How do I go about doing that? My input file: Magmas CEU rs12542019 CPNE1 RBM12 CEU... (2 Replies)
Discussion started by: evelibertine
2 Replies

5. UNIX Desktop Questions & Answers

Using grep to remove cells instead of lines

I would like to use grep to remove certain strings from a text file but I can't use the grep -v option because it removes the whole line that includes the string whereas I just want to remove the string. How do I go about doing that? My input file: Magmas CEU rs12542019 CPNE1 RBM12 CEU... (1 Reply)
Discussion started by: evelibertine
1 Replies

6. UNIX for Dummies Questions & Answers

Grep command to remove blank lines

The following grep command grep -v "^$" filename > newfilename does not populate the new file with any data. I see it search the entire input file but the output file never gets filled. Is this not the correct command for what Im looking to do? (2 Replies)
Discussion started by: aispg8
2 Replies

7. Shell Programming and Scripting

grep or sed. How to remove certain characters

Here is my problem. I have a list of phone numbers that I want to use only the last 4 digits as PINs for something I am working on. I have all the numbers in a file but now I want to be removed all items EXCEPT the last 4 digits. I have seen sed commands and some grep commands but I am... (10 Replies)
Discussion started by: Sucio
10 Replies

8. Shell Programming and Scripting

grep for certain files using a file as input to grep and then move

Hi All, I need to grep few files which has words like the below in the file name , which i want to put it in a file and and grep for the files which contain these names and move it to a new directory , full file name -C20091210.1000-20091210.1100_SMGBSC3:1000... (2 Replies)
Discussion started by: anita07
2 Replies

9. Shell Programming and Scripting

grep, remove and conconate -- xml files

suse linux 10 here. I have two xml files here and both contain <sf> and </sf> tags in almost beginning and towards the end fo the files. I need to remove the </sf> tag from the first file and the <sf> from the second file and combine both the files into one. I have tried the following... (4 Replies)
Discussion started by: basisvasis
4 Replies

10. UNIX for Dummies Questions & Answers

using grep and to remove all word with uppercase

I try to write a small script that looks in the file tt for all the words that start with m in lowercase and in which there is no uppercase. #!/bin/sh grep ^m\.*\.\.* tt (4 Replies)
Discussion started by: cfg
4 Replies
Login or Register to Ask a Question