Tux

...making Linux just a little more fun!

HOWTO kill client when Xserver dies?

=?ISO-8859-2?Q?Petr_Vav=F8inec?= [pvavrinec at snop.cz]


Tue, 15 Dec 2009 10:44:36 +0100

Hello gurus,

I run a diskless, keyboard-less pc that boots into X11 (just plain twm as a window manager). The X clients I run remotedly, on a "database server". When someone switches off the Xserver PC (i.e. flips that big red switch), the X clients aren't killed - they remain on the "database server" forever (or at least 24 hours, that's for me the same as "forever"). Is there something that I could to to force them to die automa[t|g]ically?

Thanks in advance, Petr


Top    Back


Thomas Adam [thomas.adam22 at gmail.com]


Tue, 15 Dec 2009 10:22:19 +0000

2009/12/15 Petr Vavřinec <pvavrinec@snop.cz>:

> Hello gurus,
>
> I run a diskless, keyboard-less pc that boots into X11 (just plain twm as a
> window manager). The X clients I run remotedly, on a "database server". When
> someone switches off the Xserver PC (i.e. flips that big red switch), the X
> clients aren't killed - they remain on the "database server" forever (or at
> least 24 hours, that's for me the same as "forever"). Is there something
> that I could to to force them to die automa[t|g]ically?

No.

Sometimes the simplest answers are the shortest.

-- Thomas Adam


Top    Back


Ben Okopnik [ben at linuxgazette.net]


Tue, 15 Dec 2009 07:33:45 -0600

On Tue, Dec 15, 2009 at 10:44:36AM +0100, Petr Vavřinec wrote:

> Hello gurus,
> 
> I run a diskless, keyboard-less pc that boots into X11 (just plain
> twm as a window manager). The X clients I run remotedly, on a
> "database server". When someone switches off the Xserver PC (i.e.
> flips that big red switch), the X clients aren't killed - they
> remain on the "database server" forever (or at least 24 hours,
> that's for me the same as "forever"). Is there something that I
> could to to force them to die automa[t|g]ically?

I'm not 100% clear on this "X clients on a database server" concept, but it seems like you could run a script that monitors whether the X server is alive or not, and kills the clients after the server fails to respond to some number of pings.

-- 
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *


Top    Back


=?UTF-8?B?UGV0ciBWYXbFmWluZWM=?= [pvavrinec at snop.cz]


Tue, 15 Dec 2009 15:30:51 +0100

Ben Okopnik napsal(a):

> On Tue, Dec 15, 2009 at 10:44:36AM +0100, Petr Vavřinec wrote:
>> Hello gurus,
>>
>> I run a diskless, keyboard-less pc that boots into X11 (just plain
>> twm as a window manager). The X clients I run remotedly, on a
>> "database server". When someone switches off the Xserver PC (i.e.
>> flips that big red switch), the X clients aren't killed - they
>> remain on the "database server" forever (or at least 24 hours,
>> that's for me the same as "forever"). Is there something that I
>> could to to force them to die automa[t|g]ically?
> 
> I'm not 100% clear on this "X clients on a database server" concept, but
> it seems like you could run a script that monitors whether the X server
> is alive or not, and kills the clients after the server fails to respond
> to some number of pings.
> 
> 

Hi Ben,

yes, I was afraid I will have to go that route. It's not that simple, though. When you switch the PC off and on, you'll end with two sets of clients, serving the same ip address, when only the second one is "alive". In this case I would like to kill the "older" one. It seems to me that I will have to sort by date+time and kill "everything but the first one". I was hoping that there could be a simple way...

Thanks for your valuable input,

Petr


Top    Back


Ben Okopnik [ben at linuxgazette.net]


Tue, 15 Dec 2009 09:05:05 -0600

On Tue, Dec 15, 2009 at 03:30:51PM +0100, Petr Vavřinec wrote:

> Hi Ben,
> 
> yes, I was afraid I will have to go that route. It's not that
> simple, though. When you switch the PC off and on, you'll end with
> two sets of clients, serving the same ip address, when only the
> second one is "alive". In this case I would like to kill the "older"
> one. It seems to me that I will have to sort by date+time and kill
> "everything but the first one". I was hoping that there could be a
> simple way...

Not a big problem - 'ps' can do almost all of that for you (I suspect that, if you study the 'ps' man page long enough, you can make 'ps' cook a 7-course French meal, find the treasure of Sierra Madre, polish the knob at the top of the Eiffel tower, and destroy the world. Either that, or they'll cart you off to the mental hospital because you'll believe that it can do all of those things. :)

Try something like this:

ps -eo pid,etime,args|/bin/grep '[/]X :[0-9]'

This will give you the PID, the time that the process has been running, and the process string. Sorting by running time, killing the process, etc. from there on should be pretty trivial.

-- 
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *


Top    Back