[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Hint: HowTo monitor and kill orphan processos on LTSPserver

Hi there,

today I had some time and checked our LTSP-Server for outdated processes 
- there were quite a lot - and I developped a method to single them out 
and then kill them at once!

Before putting this method onto the official howto page, I like to
- hear your opinion
- discuss about alternatives

And this is how I managed to cope with left behind processes:

1. Become root on your ltsp (su) and type (copy & paste):
ps -o "%t|%u|%c|%p" ax |grep -v root |grep -v daemon |grep [0-9]-[0-9] 

this gives all processes not run by root or as daemon, that are running 
for one day now or even longer. I tried to leave out processes whose 
name contains hyphens ('-') by claiming digits around the hyphen.

At my machine, the result was like this (quoted here):

> 19-22:56:18|a06lekub|kdeinit         | 9952 
> 19-22:56:18|a06lekub|kdeinit         | 9955
> 19-22:56:18|a06lekub|kdeinit         | 9959
>  5-06:18:29|pab12 |kdeinit         |22268
>  5-06:11:03|pab08 |kdeinit         |24062
>  5-06:11:02|pab08 |kdeinit         |24064
>  5-06:11:02|pab08 |kdeinit         |24065
>  5-06:11:02|pab08 |kdeinit         |24067
>  5-06:11:02|pab08 |kdeinit         |24069

2. If you wonder why I used the ps -o option in order to format the 
output: we need a well defined delimiter like '|' to cut out the last 
column which contains the process IDs. Before you enter next line, make 
sure that the output of 1. doesn't contain any essential processes!

for i in `ps -o "%t|%u|%c|%p" ax |grep -v root |grep -v daemon | \
grep [0-9]-[0-9] |cut -d\| --fields=4`; do kill -9 $i; done 

(This is one line, grep follows the pipe '|')

Now, this command cuts out the 4th column of the ps list and kills all 
of them with brute force (-9). 


Reply to: