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?

link|improve this question

72% accept rate
feedback

2 Answers

up vote 4 down vote accepted

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

link|improve this answer
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 6 '11 at 2: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 7 '11 at 4:03
feedback

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

link|improve this answer
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 5 '11 at 23:42
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.