Putting a program to sleep?

Kinniken

Registered
Hi, does anyone know of a way to put a program to sleep? ie, force the program to stop using CPU cycles for a time, but with the possibility to reactivate it later?
I need this because I often have to leave open apps which use a lot of CPU time even when they are hidden and idle... A way to force them to remain idle until I reactivate them would be great.

TIA,

Kinniken
 
You could get the apps PID:
ps ax | grep <app> | grep -v grep | awk '{print $1}'

Then send it a STOP signal:
kill -STOP <pid>

To start it again:
kill -CONT <pid>

You could tie it together with `backticks`

kill -STOP `ps ax | grep <app> | grep -v grep | awk '{print $1}'`
 
All I realy needed was the "-STOP" and "-CONT" options... I uses top to get the PID.
I've tested it, it seems to work great :)

Thanks!
 
Hey thanks Kinniken, that's cool!

Just out of curiosity, can you use this for httpd to freeze a connection? I seem to remember that httpd launches a new process each time it receives an HTTP request, so it would only work on one connection (at a time), right?
 
You can "renice" and application from the root account or from SUDO. This controls how much time an application gets of the CPU.
 
Back
Top