问题原文
原帖链接 · wullxz · CC BY-SA 3.0
I have a Xubuntu 14.04 Server here that runs xrdp to have a couple of users connect to it.
Now there's one problem: users who access this server via RDP from Windows thin clients often use the "X" to close the RDP session (therefore disconnect but not logout).
I know there are some options in sesman.ini to deal with that kind of behaviour, but as the manpage says, those options are currently ignored (and have been for years).
The options which would solve my problems are:
KillDisconnected
DisconnectedTimeLimit
IdleTimeLimit
Now I need to hack something that deals with disconnected sessions. My first thought was to just kill all remote users who are disconnected - but I don't know how to get that information which sessions are disconnected.
So... how do I find disconnected sessions?
Or: is there already any preferred way to deal with disconnected sessions?
已采纳解答
原帖链接 · wullxz · CC BY-SA 3.0
I finally found a solution to this.
First of all, I had to install a small program called xprintidle:
sudo apt-get install xprintidle
After that I wrote a small bash script that first fetches all displayes used by Xvnc and xrdp and then checks those display sessions if they've been idle for more than a number of minutes:
#!/bin/bash
displays=`ps aux | grep Xvnc | grep -v 'grep\|sed' | sed -r 's|.*(Xvnc :[0-9]*).*|\1|' | cut -d' ' -f 2`
limit=180
date
echo "Checking for inactive sessions!"
while read -r d; do
export DISPLAY=$d
idle=`xprintidle`
idleMins=$(($idle/1000/60))
if [[ $idleMins -gt $limit ]]; then
echo "WARN Display $d is logged in for longer than ${limit}min (${idleMins}m)"
else
echo "INFO Display $d is still ok (${idleMins}m)"
fi
done <<< "$displays"
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
