...making Linux just a little more fun!
=?ISO-8859-2?Q?Petr_Vav=F8inec?= [pvavrinec at 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?
Thanks in advance, Petr
Thomas Adam [thomas.adam22 at gmail.com]
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
Ben Okopnik [ben at linuxgazette.net]
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 * https://LinuxGazette.NET *
=?UTF-8?B?UGV0ciBWYXbFmWluZWM=?= [pvavrinec at snop.cz]
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
Ben Okopnik [ben at linuxgazette.net]
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 * https://LinuxGazette.NET *