Tombuntu

How-to Pause a Linux Process

Linux is much better at multitasking processor-intensive tasks than Windows. I remember how virus scanning used to make by old Windows PC almost unusable. Linux is much better, but occasionally you may need to pause a process that is slowing things down.

Open a terminal. Run ps or ps aux to find the PID of the process you want to stop. If you want a program to try this out with, open xeyes with xeyes& on the terminal. (The ‘&’ symbol launches the program in the background.) This will create a window with eyes that follow your cursor around, you will be able to tell that it is paused when the eyes stop moving.

xeyes doing their thing

Now run kill -STOP 7727 but replace the number with your own xeyes PID. The eyes will stop moving when they are paused.

To continue execution of xeyes, run kill -CONT 7727, again with your own PID. The eyes will start moving again.

When you are done you can end xeyes with kill 7727 (using your own PID).

Now you can pause and resume any application you like. Thanks to A Linux SysAd Blog for explaining this.

Archived Comments

ney frota

for the gui people (like my mother :)

- hit alt-f2 to pop-up run dialog
- type xeyes and hit enter
- go to: system -> administration -> system monitor
- on system monitor go to: process tab -> search for xeyes in the list
- right click xeyes and choose stop to pause the process
- right click xeyes and choose continue to release the process
- right click xeyes and choose kill to kill xeyes

terminal comands are veeeery usefull… because.. if you get a program stuck the system, the full gui gets tooooo sloooowww… so, you can hit control-alt-f1 to get a prompt, login, check process (top command can help you), kill/stop/whatever its eating you process power and hit control-alt-f7 to get back to gui

ivant

Here are some other useful commands, which can help in such tasks:

killall -STOP xeyes
will stop all processes named xeyes

pgrep -l eye
finds the PIDS of all processes, which contain ‘eye’
pkill -STOP eye
stops all the processes, containing ‘eye’

Actually, pgrep and pkill work with regular expressions.

top and htop - text based “gui” process monitors, which can sort processes based on memory consumption, cpu usage, etc. They can also send signals. I especially recommend htop. It’s very, very good!

Cheers,
Ivan

VeRTiTO

i love this post! appreciate being mentioned, keep up the linux chills!

Jadd

What about these more useful commands:
killall -s STOP xeyes
killall -s CONT xeyes

tom

haha searched for this and noticed that it DIDN’T work for the process I wanted to pause: cp (copy)

there will be more processes you can’t pause I think

Keilaron

Another way to get the pid of xeyes without using killall or a “contains”-type search is to use pidof, e.g.:
kill `pidof xeyes`
You can use -s to force only one pid to be returned, e.g.:
kill `pidof -s xeyes`

Anonymous

thanks yar its working

milind

but how can we stop other processes … like copy for example

Anonymous

ctl-z to suspend

Bulat

then to turn this process from suspended state run fg interminal. So we have ‘ctrl-z’ to suspend, fg in terminal to resume

roger ward choirist

If you want to stop copy you can use “ctrl+c” (interrupt it), or kill

Respond via email