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
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.
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
Summary: Hi, I have to move files older than 4 hours from a directory to another. How to find these file ? The find command with -mtime can't be applied because time is up than 24 hours. Thanks ...