Computing.Net > Forums > Unix > How to kill processes older than x

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

How to kill processes older than x

Reply to Message Icon

Name: rohartma
Date: November 21, 2002 at 23:36:13 Pacific
OS: solaris 2.6
CPU/Ram: unknown
Comment:

I need to write a script to kill user-processes
from "ps -ef"-list older than x days.
Thanks in advance.



Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: November 22, 2002 at 04:33:32 Pacific
Reply:

Date might not be a good kill criteria. Many deamons are started at boot time and stay active till the machine is rebooted. init, nfsd, portmap are a few that come to mind. Probably your machine would not be happy if you killed off these system daemons. Another criteria perhaps?


0

Response Number 2
Name: rohartma
Date: November 22, 2002 at 06:56:12 Pacific
Reply:

hi david,

thanks for your response. sure, but i want to kill just only user-processes (no deamons, no root-processes,etc...).the output of
"ps -ef |grep ts08037I |awk '{print$5,$6}'"
is:

Sep 30
Nov 07
Sep 11
Sep 06
Sep 11
Sep 06
Sep 11
Sep 30
Nov 07

how can i compare this kind of date format with system date minus 3 days for example?



0

Response Number 3
Name: David Perry
Date: November 22, 2002 at 13:01:54 Pacific
Reply:

There is not a straight forward was as the shell does not work in epoch time. This leaves it up to you to develop case statements for each month and again for the days. Tiresome work. An alternative is to do this in perl that has access to many date manipulation libraries. Probably converting in all to Julian dates would be easiest for you. Jan 31 is day 31. Feb 28 is day 59. March 31 is day 90 and so on. Then you are left with simple integer math.


0

Response Number 4
Name: rohartma
Date: November 23, 2002 at 08:27:28 Pacific
Reply:

hi david,
that's a good idea! Thanks a lot.
have a nice weekend.
bye
robert


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: How to kill processes older than x

How to find file older than 4 hours www.computing.net/answers/unix/how-to-find-file-older-than-4-hours/5145.html

How to delete a file named -x www.computing.net/answers/unix/how-to-delete-a-file-named-x/3350.html

How to kill connection in unix www.computing.net/answers/unix/how-to-kill-connection-in-unix/4128.html