Tuesday, August 28, 2012

Pausing a Process in Linux

I was recently tasked to investigate on Java memory leak problem in production server. In order to do that, I'll have to create a memory dump. But before that, I'll have to pause the Java process from running and then resume the process after I've finished dumping the memory.

So how to do that in Linux?

To pause a process in Linux, just run the following command.

kill -SIGSTOP [PID]

Note: PID = process id, use ps command to see the process id.

To resume a paused process in Linux, run the following command.

kill -SIGCONT [PID]

That's about it. Don't worry, I didn't run this in production server, we have staging server for such troubleshooting purpose.

Chill.