UbuntuHelp:UbuntuLTSP/KillProcOnDisconnect
来自Ubuntu中文
点击翻译: |
English |
请不要直接编辑翻译本页,本页将定期与来源同步。 |
Kill remaining processes if the client is no longer reachable
This page is specific to Ubuntu versions 8.10 |
If you find this information applicable to additional versions/releases, please edit this page and modify this header to reflect that. Please also include any necessary modifications for this information to apply to the additional versions.
On running some LTSP Clients on the floor of a school and people randomly powering off client machines we had the problem that some processes remaind running on the server. Sometimes that caused a further problem when the clients were powered on again and the automated login failed. The gnome-watchdog was no solution because the only application running is the webbrowser (Opera in this case). But i got a lot of information out of this scripts. thanks!
The Xsession script for the Kiosk
sudo vi $HOME/.xsession
#!/bin/sh #!/bin/sh # $HOME/.xsession file for all kiosk users. # wait 2 seconds for dying watchdog script of an old session # which is still running after a <Ctrl><Alt><Backspace> sleep 2 xmodmap -e 'clear Lock' # Start the watchdog if [ -n "$LTSP_CLIENT" ] ; then [ -e /home/kiosk-watchdog.sh ] && /home/kiosk-watchdog.sh & fi # Start Opera Browser for the kiosk /usr/bin/opera -k \ -kioskresetstation \ -kioskwindows \ -kioskbuttons \ -nodownload \ -noexit \ -nokeys \ -nomail \ -nomaillinks \ -nomenu \ -nominmaxbuttons \ -noprint \ -nosave \ -nosession \ -resetonexit \ http://www.roland.at \ & sleep 4 exec /usr/bin/metacity
The watchdog script
sudo vi /home/kiosk-watchdog.sh
#!/bin/bash #!/bin/bash # # Kill all processes which may be left after shutdown of a kiosk set -x PROG=`basename $0` # do not run as root if [ `id -u` -eq 0 ] ; then exit 1 fi # run as long as we can ping the client machine we are running for sleep 10 i=3 while [ $i -gt 0 ] ; do sleep 1 if ping -c1 -n $LTSP_CLIENT | grep "1 packets transmitted, 1 received" >/dev/null 2>&1 ; then i=2 else i=`expr $i-1` fi if ! last $USER | grep "still" >/dev/null 2>&1 ; then # echo "" >/dev/null 2>&1 # else i=0 fi done # kill all our processes after machine shutdown # 1. try with -SIGTERM, except the process of this script pkill -SIGTERM -U $USER -v -f $PROG >/dev/null 2>&1 sleep 2 # 2. do it the hard way with -SIGKILL pkill -SIGKILL -U $USER -v -f $PROG >/dev/null 2>&1 sleep 1 # 3. a last try to kill everything what is left of us pkill -U $USER >/dev/null 2>&1
do not forget to make it executable: sudo chmod o+x /home/kiosk-watchdog.sh