8

I started a very resources-consuming process on a remote server via ssh. It is an optimization problem run in MATLAB. It takes full memory and CPU. In fact, I am not even able to ssh to the machine, which doesn't reply at all. How do I kill that process? I don't have root access.

2
  • From work experience, you may have to reboot the machine. However I'm curious to know if there's a more canonical way to do it.
    – rahmu
    Nov 29, 2011 at 0:03
  • rahmu: I don't even know where the machine is located :( Nov 29, 2011 at 0:05

2 Answers 2

14

If your user started the process, and you only have access remotely, your options are limited.

I would try remotely killing the processes, This may take some time to get queued!

ssh -l $USER $HOSTNAME 'pkill -9 MATLAB'

If this executes, but does not kill the running process. You could always kill all processes created by your user. this would be a more last resort, obviously avoid if you know the process name.

ssh -l $USER $HOSTNAME 'pkill -9 -u $USER'

If you have any KVM or IPMI access, this would be the time to bust it out.

3
  • the machine doesn't react to any ssh request Nov 29, 2011 at 0:23
  • also, isn't the option '-p' is ssh to select the port? Nov 29, 2011 at 0:30
  • Sorry, I mistakenly typed in MySQL user/pass options. How long did you wait for the machine to respond? You have eaten all resources, it could take some time. This is also why, you want to do the command in the connection. Nov 29, 2011 at 0:37
7

If the machine doesn't react to any network request, you're hosed. By a simple process of elimination, if you can't get remote access, you need console access.

Be patient. If the machine is swapping heavily, it may take several minutes to respond.

For the future, keep an ssh session open, and have the process ID of the potentially troublesome process ready. All mainstream shells have the kill command built-in, so that you can kill a process even if the machine is heavily under load or your user has reached its process limit.

Also for the future, you can limit the resources that the Matlab process can allocate by running the ulimit command in the shell where you start it. In particular, ulimit -Sv 42 will limit the total amount of virtual memory that any one process can allocate to 42kB (the limit applies to each process subsequently started by that shell).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .