# Killing idle sessions

## Raniz

Running who I see that I have som active sessions...

```
┌─ 02:32 PM raniz@raniz $ who

root     tty2         2005-09-14 12:48

raniz    :0           2005-09-27 14:25

raniz    pts/0        2005-09-27 14:25

raniz    pts/1        2005-09-27 14:25

raniz    pts/4        2005-09-09 15:28 (elg-6.efd.lth.se)
```

Though, the last one is an old login I made from school - and I'm certainly not logged in anymore...

How do I get rid of it?

I can't find any running apps belonging to that session...

```
┌─ 02:36 PM raniz@raniz $ ps -tf pts/4

ERROR: TTY could not be found.

********* simple selection *********  ********* selection by list *********

-A all processes                      -C by command name

-N negate selection                   -G by real group ID (supports names)

-a all w/ tty except session leaders  -U by real user ID (supports names)

-d all except session leaders         -g by session OR by effective group name

-e all processes                      -p by process ID

T  all processes on this terminal     -s processes in the sessions given

a  all w/ tty, including other users  -t by tty

g  OBSOLETE -- DO NOT USE             -u by effective user ID (supports names)

r  only running processes             U  processes for specified users

x  processes w/o controlling ttys     t  by tty

*********** output format **********  *********** long options ***********

-o,o user-defined  -f full            --Group --User --pid --cols --ppid

-j,j job control   s  signal          --group --user --sid --rows --info

-O,O preloaded -o  v  virtual memory  --cumulative --format --deselect

-l,l long          u  user-oriented   --sort --tty --forest --version

-F   extra full    X  registers       --heading --no-heading --context

                    ********* misc options *********

-V,V  show version      L  list format codes  f  ASCII art forest

-m,m,-L,-T,H  threads   S  children in sum    -y change -l format

-M,Z  security data     c  true command name  -c scheduling class

-w,w  wide output       n  numeric WCHAN,UID  -H process hierarchy

zsh: exit 1     ps -tf pts/4
```

----------

## adsmith

kill <pid of login process>

----------

## Raniz

 *Raniz wrote:*   

> I can't find any running apps belonging to that session...
> 
> ```
> ┌─ 02:36 PM raniz@raniz $ ps -tf pts/4
> 
> ...

 

Haven't got any pids to kill

----------

## adsmith

drop the "-f", or put it before the "-t".  ps thinks you're looking for terminal "f pts/4"

```

abe@tock ~ $ w

 08:52:25 up 15:42,  3 users,  load average: 0.47, 0.14, 0.16

USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT

abe      :0        Mon17   ?xdm?  21:35   1:37  enlightenment

abe      pts/4     08:37   14:37   0.19s  0.19s bash

abe      pts/5     08:52    0.00s  0.17s  0.00s w

abe@tock ~ $ ps -tf pts/4

ERROR: TTY could not be found.

********* simple selection *********  ********* selection by list *********

-A all processes                      -C by command name

-N negate selection                   -G by real group ID (supports names)

-a all w/ tty except session leaders  -U by real user ID (supports names)

-d all except session leaders         -g by session OR by effective group name

-e all processes                      -p by process ID

T  all processes on this terminal     -s processes in the sessions given

a  all w/ tty, including other users  -t by tty

g  OBSOLETE -- DO NOT USE             -u by effective user ID (supports names)

r  only running processes             U  processes for specified users

x  processes w/o controlling ttys     t  by tty

*********** output format **********  *********** long options ***********

-o,o user-defined  -f full            --Group --User --pid --cols --ppid

-j,j job control   s  signal          --group --user --sid --rows --info

-O,O preloaded -o  v  virtual memory  --cumulative --format --deselect

-l,l long          u  user-oriented   --sort --tty --forest --version

-F   extra full    X  registers       --heading --no-heading --context

                    ********* misc options *********

-V,V  show version      L  list format codes  f  ASCII art forest

-m,m,-L,-T,H  threads   S  children in sum    -y change -l format

-M,Z  security data     c  true command name  -c scheduling class

-w,w  wide output       n  numeric WCHAN,UID  -H process hierarchy

abe@tock ~ $ ps -t pts/4

  PID TTY          TIME CMD

 4143 pts/4    00:00:00 bash

```

----------

## Raniz

Still can't find anything...

----------

## adsmith

ermm.. that really shouldn't be true.    'ps -t pts/4' really gives nothing, while 'w' lists pts/4 ?

I'll state the obvious and almost-true for *nix systems: "everything is a file and everything is a process".

----------

## Raniz

```
┌─ 04:35 PM raniz # who

root     tty2         2005-09-14 12:48

raniz    :0           2005-09-27 14:25

raniz    pts/0        2005-09-27 14:25

raniz    pts/1        2005-09-27 14:25

raniz    pts/4        2005-09-09 15:28 (elg-6.efd.lth.se)

┌─ 04:35 PM raniz # ps -t pts/0

  PID TTY          TIME CMD

zsh: exit 1     ps -t pts/0

┌─ 04:35 PM raniz # ps -t pts/4

ERROR: TTY could not be found.

********* simple selection *********  ********* selection by list *********

-A all processes                      -C by command name

-N negate selection                   -G by real group ID (supports names)

-a all w/ tty except session leaders  -U by real user ID (supports names)

-d all except session leaders         -g by session OR by effective group name

-e all processes                      -p by process ID

T  all processes on this terminal     -s processes in the sessions given

a  all w/ tty, including other users  -t by tty

g  OBSOLETE -- DO NOT USE             -u by effective user ID (supports names)

r  only running processes             U  processes for specified users

x  processes w/o controlling ttys     t  by tty

*********** output format **********  *********** long options ***********

-o,o user-defined  -f full            --Group --User --pid --cols --ppid

-j,j job control   s  signal          --group --user --sid --rows --info

-O,O preloaded -o  v  virtual memory  --cumulative --format --deselect

-l,l long          u  user-oriented   --sort --tty --forest --version

-F   extra full    X  registers       --heading --no-heading --context

                    ********* misc options *********

-V,V  show version      L  list format codes  f  ASCII art forest

-m,m,-L,-T,H  threads   S  children in sum    -y change -l format

-M,Z  security data     c  true command name  -c scheduling class

-w,w  wide output       n  numeric WCHAN,UID  -H process hierarchy

zsh: exit 1     ps -t pts/4
```

Well something's not right here...

----------

## adsmith

perhaps udev/devfs is confused and not properly creating/destroying login devices??

----------

## Raniz

```
┌─ 05:15 PM raniz # ls /dev/pts                                                                                                                                                                                        /usr/src

0  1  2
```

Odd... Where does who get it's info from?

----------

## adsmith

/var/log/utmp or /var/log/wtmp, I think.

----------

## Esel Theo

/var/log/utmp and /var/log/wtmp hold the information who is currently logged in to the system. The files are maintained whenever you log in or off (by the login process?). If you have not been logged off correctly from the system, this file does not get updated properly (e.g., if your network connection breaks down unexpectedly). This makes your "session" still appear with `who'. Being listed in `who' does not mean that there are still any resources (processes, etc.) used by the session, it just means that there is an entry in the above files. So no need to worry, just ignore those "sessions".

Btw.: You might want to try `w' instead.

----------

