如何断开无效的用户登录会话
昨天发现OpenBSD系统上有一个登录的会话,已经空闲了9天。想必是哪天在手机上测试SSH端口转发后造成的。
#w
6:07PM up 12 days, 21:42, 2 users, load averages: 0.24, 0.14, 0.09
USER TTY FROM LOGIN@ IDLE WHAT
acheng p0 180.116.63.38 6:00PM 0 w
acheng p4 114.227.123.110 27Jul12 9days –
6:07PM up 12 days, 21:42, 2 users, load averages: 0.24, 0.14, 0.09
USER TTY FROM LOGIN@ IDLE WHAT
acheng p0 180.116.63.38 6:00PM 0 w
acheng p4 114.227.123.110 27Jul12 9days –
该如何把它解决掉呢?查了一下,ttyp4上已经没有什么进程了,想用kill也没机会了。
#ps -t p4
PID TT STAT TIME COMMAND
PID TT STAT TIME COMMAND
正常情况下,即使用户会话断开,也会有一些进程在运行,我们可以通过上面这个命令找到这些进程,然后使用kill命令把它们干掉。于是我发邮件到misc@ 请教。经指点后发现,这是因为那个会话的SSHD没有正常退出,导致了utmp文件中相应的记录没有被清理,从而出现了w命令报告有用户登录会话,但却没有任何进程的情况出现。系统重启后这个不是问题的问题就会自动消失。
同时,推荐阅读utmp的用户手册来了解更多。
man utmp
….
After the new lastlog record is written, the utmp file is opened and the
utmp record for the user is inserted. This record remains until the user
logs out at which time it is deleted. The utmp file is used by the
programs rwho(1), users(1), w(1), and who(1)….
….
After the new lastlog record is written, the utmp file is opened and the
utmp record for the user is inserted. This record remains until the user
logs out at which time it is deleted. The utmp file is used by the
programs rwho(1), users(1), w(1), and who(1)….
No comments yet.