Need to kill processes that are older than 3 days


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to kill processes that are older than 3 days
# 1  
Old 07-09-2009
Need to kill processes that are older than 3 days

Hi, I need a .ksh script that lists all the process that are currently running and older than 3 days. once the process list is available i need to mail the list and then kill those processes.

Quick response is highly appreciated Smilie

Thanks in Advance!!!
Sri
# 2  
Old 07-09-2009
can you give us an understanding of why you need this??

many of the core OS PID's will be more than three days old....


and also what OS ??
# 3  
Old 07-09-2009
There are no on-the-fly commands to do this:

We can go with a logic as ... if a pid is older than 24 hrs, it will be displayed in Mon hr format..

eg: Jun 09

Try the below snippet to take only those pids which are older than 24 hrs. You can put in your logic on top of the snippet given below to look for pids older than "n" days

ps -ef| sed '/\([JFMAMSOND][aepuco][nbrylgptvc] [0-9][0-9]\)/!d' | awk '{ print $2" "$5":"$6; }'
# 4  
Old 07-10-2009
Thanks Guys, let me clarify the things i need here. I have few process scheduled to run everyday. if by chance any process doesn,t complete within 3 days i need to kill them. ps list will be very big so i may miss few process while manually checking.
I do not want to kill any sys process. i just want to generate list of all the .ksh jobs and its child ps that are older than 3 days. later looking at that list i will decide what to kill. (it will be easy to look into the list which will have only 3 days older ps)
And My OS is Hp-Ux.

Last edited by Sriranga; 07-10-2009 at 01:14 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove lines older than 30 days

Hi Experts/Gurus, Is there a way to remove lines in a file that are older than x days (i.e. 30 days) based on the date stamp in the first column? Example. $ date Sat Jan 11 14:12:06 EDT 2014 $cat sample.txt 10-10-2013 09:00:01 AM|Line test 1234567 16-10-2013 08:30:00 AM|Line test... (6 Replies)
Discussion started by: brichigo
6 Replies

2. HP-UX

listing processes older than n days

Hello; trying to find processes older than n days, mostly user shells Tried the following code on 11.31 box: in this case older than 5 days UNIX95= ps -ef -o user,pid,ppid,cpu,etime,stime | grep "-" | awk '{print $2}' | xargs ps -ef|grep -v '?' |\ awk '$5 !~ ""' | awk '($5 ~ "$(date "+%b")")... (6 Replies)
Discussion started by: delphys
6 Replies

3. UNIX for Dummies Questions & Answers

Size of files which are older than x days

Hi I want to find the total space used by the files which are older than x days find ./ -type f -mtime +x-days -name "G00*" -exec du {} \; | awk '{total+=$1}END{print "TOTAL" total}' Total prints as 17.20 MB ( total / 1024*2 ) But actual size of it will be around 18.5 GB... (1 Reply)
Discussion started by: rakeshkumar
1 Replies

4. UNIX for Dummies Questions & Answers

Files older than 50 days

Hi All, OS :- HP-UX wm5qa B.11.23 U ia64 1119805695 unlimited-user license I need to search files older than 50 days. I've used following command in order to search desired files, I also discoverd, it's showing today's files as well. Do you have any clue with this ? wmqa1> find .... (4 Replies)
Discussion started by: alok.behria
4 Replies

5. UNIX Desktop Questions & Answers

Find files older than 10 days

What command arguments I can use in unix to list files older than 10 days in my current directory, but I don't want to list the hidden files. find . -type f -mtime +15 -print will work but, it is listing all the hidden files., which I don't want. (4 Replies)
Discussion started by: Pouchie1
4 Replies

6. Shell Programming and Scripting

How to find files older than 30 days

Dear Friends, I have two queries. 1) I want to see the list of folders which were created 29 days ago. 2) I want to see the folders in which last created file is older than 29 days. Can it be done? Thank you in advance Anushree (4 Replies)
Discussion started by: anushree.a
4 Replies

7. Solaris

Delete files older than 30 days

Hi all, I want to delete log files with extension .log which are older than 30 days. How to delete those files? Operating system -- Sun solaris 10 Your input is highly appreciated. Thanks in advance. Regards, Williams (2 Replies)
Discussion started by: William1482
2 Replies

8. Solaris

Copying files older then 2 days

Hi everyone :) I have a little question here, at my work, we have a system running Solaris 10 - with an attached EMC SAN, the SAN is running out of space, and we are moveing the data to a new EVA SAN. The problem here is, that there are over 35.000.000 files on the system, and constantly 30... (4 Replies)
Discussion started by: Skovsen
4 Replies

9. Shell Programming and Scripting

Deleting files older than 7 days

Hi Guys, I want to delete folder/files older than 7 days. Im using the command below. find /test/test1 -mtime +7 -print0 | xargs -0 rm -Rf /test/test1/* which works ok, but it deletes the test1 folder as well which i dont want. The test1 folder will have a list of sub-folders which in... (4 Replies)
Discussion started by: shezam
4 Replies

10. Shell Programming and Scripting

List directory 7 days older

Say folder archive/ contains many folder each created on a day. this folder may contain files. i want to write a script to delete all the folder inside archive/ which are 7 days older. i used the below script for the reason. find archive -mtime +7 -type d -exec rm -r {} \; pls suggest me if... (3 Replies)
Discussion started by: krishnarao
3 Replies
Login or Register to Ask a Question