Daniel's Blog

Killing old logins

From time to time, a user will be logged in and then have their internet connection terminated or interrupted.

Their connection is ended, but their terminal session is still running in the background.

I've seen this happen and not discovered it until an employee has left the organization and I need to remove their user and I receive an error while trying to do so.

So whenever this happens to you, you can clean up the logins the next time you login.

$ ps uf
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
me        1366  0.0  0.0  23200  1740 pts/8    Ss+   2019   0:00 -bash
me       11890  0.0  0.0  23196  1748 pts/9    Ss+   2019   0:00 -bash
me       15179  7.0  0.0  23964  9020 pts/0    Ss   23:52   0:00 -bash
me       15223  0.0  0.0  34420  2904 pts/0    R+   23:52   0:00  \_ ps auf
--noclear tty1 linux

The first two logins are old (from 3 years ago!)

$ kill -SIGTERM  1366  
$ kill -SIGTERM  11890  

Now they are gone:

$ ps uf
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
me       15179  0.2  0.0  23964  9088 pts/0    Ss   23:52   0:00 -bash
me       16250  0.0  0.0  34420  2960 pts/0    R+   23:53   0:00  \_ ps uf