How to Kill and Alternate X session via cli
Posted
by
L. D. James
on Ask Ubuntu
See other posts from Ask Ubuntu
or by L. D. James
Published on 2014-08-19T14:28:39Z
Indexed on
2014/08/19
16:30 UTC
Read the original article
Hit count: 355
Can someone tell me how to remove dormant X sessions. This question is similar to Logging out other users from the command line, but more specific to controlling X displays which I find hard to kill.
I used the command "who -u" to get the session of the other screens:
$ who -u
Which gave me:
user1 :0 2014-08-18 12:08 ? 2891 (:0)
user1 pts/26 2014-08-18 16:11 17:18 3984 (:0)
user2 :1 2014-08-18 18:21 ? 25745 (:1)
user1 pts/27 2014-08-18 23:10 00:27 3984 (:0)
user1 pts/32 2014-08-18 23:10 10:42 3984 (:0)
user1 pts/46 2014-08-18 23:14 00:04 3984 (:0)
user1 pts/48 2014-08-19 04:10 . 3984 (:0)
The kill -9 25745
doesn't appear to do anything.
I have a workshop where a number of users will use the computer under their own login. After the workshop is over there are a number of logins that are left open. I would prefer to kill the open sessions rather than try to log into each users' screen.
Again, this question isn't just about logging users' out. I'm hoping to get clarity also for killing/removing stuck processes that are hard to kill.
New Info
While still pondering how to kill the process I wrote the following script, which did it:
#!/bin/bash
results=1
while [[ $results > 0 ]]
do
sudo kill -9 25745
results=$?
echo -ne "Response:$results..."
sleep 20
done
After a graceful waiting period, if there isn't a better answer I'll mark this as answered with this resolution. This may resolve the problem with other stuck processes I have had in the past.
© Ask Ubuntu or respective owner