Previous Page
PCLinuxOS Magazine
Article List
Next Page

Pause, Then Resume, A Process On Linux

by Paul Arnote (parnote)

If you've spent any amount of time on the command line, I'm certain that the following has happened to you. Let's say you start a "process" that tends to take up a lot of time. That process also consumes a lot of resources. But, you also have other things you need to get done, and you need those resources, at least temporarily.

You could just let the lengthy process continue until it is finished. But, you can also temporarily stop that process, and resume it after you've finished the other things you need to get done. Keep in mind that this only works for the current session, and will not transfer between a reboot or restart.

The best way to explain how this works is to provide an example. Let's say that we used the wget command to download the LXDE Mini PCLinuxOS community ISO (entered all on one line, of course).

wget &

We put the "&" at the end of the line to force the wget command to execute in the background.

Now, run the ps command.

[parnote-lenovo@localhost ~]$ ps
  PID TTY          TIME CMD
 6464 pts/0    00:00:00 bash
18983 pts/0    00:00:00 wget
19015 pts/0    00:00:00 ps

Note the PID of the process for wget. We will need the PID to pause the wget process.

At the command prompt, enter the following:

kill -STOP 18983

The "18983" parameter is the PID for the wget process, which we noted when we ran the ps command. You will get a confirmation message that the wget process has been stopped. You can check in your graphical file manager by highlighting the incomplete download, and you will notice that the filesize is no longer increasing.

When you are ready to resume the wget process, enter the following command:

kill -CONT 18983

The wget process will graciously pick up right where it left off, and complete as if you never paused it.

This probably isn't going to work very well with GUI processes. As you might notice, GUI processes never even showed up in the list produced by the ps command. GUI processes will show up though, if you issue the ps command with the -A flag (ps -A). I wouldn't be eager to try it however, as this method works primarily with tty processes.

Isn't it nice to be able to have full and complete control over your Linux machine? Now, you can pause those lengthy processes, then resume them when you are ready.

Previous Page              Top              Next Page