Linux allows you to pause a running process rather than quitting or killing it. Pausing a process just suspends all of its operation so it stops using any of your processor power even while it still resides in memory.
This may be useful when you want to run some sort of a processor intensive task, but don't wish to completely terminate another process you may have running. Pausing it would free up valuable processing time while you need it, and then continue it afterwards.
To pause a process in Linux we first need to obtain it's PID, or Process ID number. There are various ways of getting the PID, and here are two. The simplest is the pidof command with the name of the program you wish to pause:
pidof totem
Another way is to use a ps command and search through the results for the program name:
ps aux | grep totem
In this command ps aux lists all of the processes, the pipe sign tells it to filter by the next command (so called piping), and the next command, which is grep totem, searches through the results to display only those mentioning the totem process. The first number in the results should be your PID.
Once you have your process ID you can pause this process by running the kill command with the -STOP option followed by the PID number:
kill -STOP 10463
Of course, the above number is just an example. Replace it with your own. In this example the above command will stop Totem from running.
Totem is a nice example to try out because you can see the immediate effect if you're playing a movie in it. The movie will stop the moment you run this command. This isn't the same as pressing the "pause" button in the player controls, because the whole process is completely suspended, not just the playing of a movie. You can see this by trying to press any of the control buttons; they wont respond. The program is frozen, even though you can still move its window.
To continue the process just run the kill command with the -CONT option and your PID:
kill -CONT 10463
If you've been playing a movie in Totem, as per this example, your movie would immediately proceed and the button controls in it will work as normal.
And that's how you pause and continue processes in Linux!
Carl Oxwall says
Thanks for this! Our daughter is spending (too) much time playing Minecraft on this old Slackware rig that I've put up more or less specifically for this purpose and sometimes she gets so glued to it so that even if we yell "Dinner time!" from the kitchen she just yells back "Wait!" followed by another "Wait!" (five minutes later) and this situation is not desirable by any means. Now I've simply put a shotcut on my Android phone that connects to the computer over SSH and pauses the process rather than killing it, then I simply let her return after finishing dinner. I know, this may not be ideal parenting. After all, you want your kid(s) to actually do as told by just listening, not by technical restrictions. Anyways, this feels like a doable workaround at the moment, until we get better control of things! Again, thanks! 🙂
cst1992 says
Exactly what I'd want in a geeky parent! Good job!