2

The number of allocated ptys (/proc/sys/kernel/pty/nr) on my linux server is constantly growing, and exceeds the number of active logins, terminals and screen sessions by orders of magnitude. Only a system restart resets seems to reset it.

How can I find out which process is eating up the pty's?

I tried the suggestion in answer 1, but

# lsof -n | grep pts | wc -l
137
# cat /proc/sys/kernel/pty/nr 
696

# uname -a
Linux spitzer 2.6.32-34-server #77-Ubuntu SMP Tue Sep 13 20:54:38 UTC 2011 x86_64 GNU/Linux
Nikratio
  • 645
  • 5
  • 13

3 Answers3

4

Ptys are file handles. You can use lsof to find out which process is keeping which files open.

# lsof -n | grep pts
Kvisle
  • 4,193
  • 24
  • 25
4

According to grawity's answer on superuser, what you are seeing is due to a bug in linux. /proc/sys/kernel/pty/nr is not decremented when a pty is no longer used. That is why lsof is showing a lower number. This was noticed in November 2009 but not fixed until August 2011.

sciurus
  • 12,678
  • 2
  • 31
  • 49
0

A pty can have more than one 'file' associated with it. If you take that into account, the kernel.pty.nr number will match the lsof number.

cat /proc/sys/kernel/pty/nr

10

lsof -n | fgrep pts | wc -l

58

lsof -n | fgrep pts | sed 's/  */ /g' | cut -f9 -d' ' | sort | uniq | wc -l

10
Jenny D
  • 27,780
  • 21
  • 75
  • 114