2

On a mis-configured or buggy network filer (NFS NAS) writing a large file can cause the filer to freeze.

For diagnostics I need to be able to:

  1. Suspend (or in other words temporary freeze) all processes of a particular user
  2. Resume the user

Basically, like a kill -s SIGSTOP and kill -s SIGCONT but for the entire user.

To do that, is there a way to temporary take away all CPU-time from a user in Linux?

Aleksandr Levchuk
  • 2,415
  • 3
  • 21
  • 41

2 Answers2

4

You can do this more reliably than SIGSTOP and SIGCONT by using the cgroup freezer.

sciurus
  • 12,493
  • 2
  • 30
  • 49
  • I'm going to give it a try. Looks like I just have to echo pid of all running processes of the user into /tasks. It's a bit annoying that if the user tries to open another SSH connection then new processes will not be added to the cgroup. – Aleksandr Levchuk May 06 '11 at 02:06
  • I could not try it. I have 2.6.36 openvz kernel for some reason I don't have the cgroup fs type when I try to do `mount -t cgroup -ofreezer freezer /containers` but I seems to work on Ubunut 11.04 (Linux 2.6.38) – Aleksandr Levchuk May 07 '11 at 04:03
0

Try pkill -STOP -u <username> and resume with pkill -CONT -u <username>

gravyface
  • 13,947
  • 16
  • 65
  • 100
  • This could cause problems depending on order in which pkill sends the signals. For example, suspending a child process before the parent will cause bash for-loops to break. Also, what if the user already had some processes suspended (e.g. Ctrl-Z)? – Aleksandr Levchuk May 05 '11 at 23:42