How to detect x2go idle sessions?
6,099
See x2golistsessions_root
here's a script I wrote:
LIMIT_DAYS=12
for ll in `x2golistsessions_root`; do
#Get the date of last use of the session
lastd=`echo $ll | awk -F \| '{print $11}' | awk -F T '{print $1}';`
#Date in seconds
lastsec=`date -d "$lastd" +%s`
#Current date in seconds
now=`date +%s`
days=`echo $(( ($now - $lastsec) /60/60/24 ))`
if [[ $days -gt $LIMIT_DAYS ]]; then
sid=`echo $ll | awk -F \| '{print $2}'`
echo "terminating session: $sid, $days days old, lastd: $lastd, lastsec: $lastsec, now: $now"
x2goterminate-session $sid
fi
done
Related videos on Youtube
Author by
user2436428
Updated on September 18, 2022Comments
-
user2436428 over 1 year
Using
who -u
andw
commands, we can find out which ssh sessions are idle for how many time-period. But these commands don't capture x2go sessions; x2go works over ssh though.I am looking an equivalent of '
who u
' for x2go sessions, so that idle sessions can be terminated after some specified period.Thanks
-
David Foerster over 8 yearsWhat does it do and how would you use it?