By Rob Griffiths
Every program youâ€™re using on your Mac (obviously) uses some portion of your CPU. And the more youâ€™re asking a given program to do, generally speaking, the more of your CPU it will use. For instance, Safari with one window open isnâ€™t going to load your CPU too heavily. But open seven new windows, put six tabs in each window, and then load up 42 of your favorite web-based Flash games, and youâ€™ll find that Safari is now demanding quite a bit from the CPU. You can see exactly how much by launching Activity Monitor (in Applications > Utilities) and looking at the â€˜%CPUâ€™ column next to Safariâ€™s entry in the process list.
Generally, any one program using some portion of your CPU isnâ€™t a problem, as your CPU is seldom taxed to 100% for extended periods of time. But what if youâ€™d like to recapture some of that CPU time for other uses? Consider the example above with 42 Flash games running. In the midst of your gaming-fest, you realize that you need to finish a critical project in iDVD. iDVD works best when you can give it as much of the CPU as possible, especially when rendering and burning a project. However, with 42 Flash games running in Safari, you may not have a lot of spare cycles available.
You could, of course, quit Safari, but that means youâ€™ll have to load Safari, and then find and reload all 42 games when you finish your iDVD project. Youâ€™d also lose that new world record score that you were racking up in Burger Dude III, which would be a real shame. So wouldnâ€™t it be great if there were a way to pause Safari, thereby freeing up the CPU, do your iDVD work, and then jump right back into Safari? Obviously, there must be a way to do this, or there wouldnâ€™t be much point to this hint, would there!?
The secret to temporarily stopping any program is to use the Terminal (in Applications > Utilities) and a special mode in the kill program which will simply pause a given application, instead of completely killing it (which is what kill normally does. The first thing you need to do is figure out which program youâ€™d like to pause. To do that, youâ€™ll use two other Unix commandsâ€”one called ps (process status) and the other called grep, a search utility. Thatâ€™s because we need something called the process ID (or pid) of the program we wish to pause, instead of its name.
For purposes of this example, assume itâ€™s Safari youâ€™d like to pause. In the Terminal, type this command:
ps -ax | grep Safari
The ps -ax portion of the command lists all processes, just to make sure you see everything. The pipe symbol (the vertical bar) then passes this list of processes to grep, which searches for the string Safari. By using grep, we wonâ€™t have to look at the output for the processes we donâ€™t care about. The output of this command should look something like this:
6537 ?? S 20:05.19 /Applications/Safari.app … 0_51642369
8932 p1 S+ 0:00.01 grep Safari
(Note that I trimmed some characters from the first line to make the display a bit narrower.) The first line shows the actual Safari task; the second is the result of grep Safari finding itself within the process list, and it can be ignored. To find any other running programâ€™s process ID, just replace Safari with a portion of the programâ€™s name (i.e. Keynote or Word).
The process ID is the first number in the outputâ€”6537 in this case. To temporarily pause Safari, just type:
kill -STOP 6537
Replace 6537 with the pid number of the program you wish to pause, obviously! There wonâ€™t be any output from this command; youâ€™ll just get the Terminal prompt again. And Safariâ€™s open windows will still be open in the background. But if you switch back to the Activity Monitor (or use top in the Terminal), youâ€™ll now see that Safari is using 0.0% of your CPU. And if you try to use the program, youâ€™ll find that itâ€™s completely non-responsive. In fact, a control-click on Safariâ€™s Dock icon will show you the â€œapplication not respondingâ€ pop-up menu, along with a Force Quit option. But donâ€™t worry, Safariâ€™s just been put into suspended animation. Go off and do whatever it is you needed to do.
When youâ€™re done, switch back to the Terminal, and type:
kill -CONT 6537
This will bring Safari back to life (remember to replace 6537 with the pid you found for your particular program), and ready to go right where you left it. Note that, depending on what pages you may have loaded, you may have some usability issues. For instance, if you pause Safari for 15 minutes while on your bankâ€™s site, and your bank has a 10-minute auto-logout routine, then you may find yourself logged out as soon as the site is able to check the time again.
Generally speaking, however, using kill -STOP is a safe way to temporarily place any application into a state of suspended animation. Itâ€™s always a good idea when doing something like this, however, to not leave any unsaved documents openâ€”make sure you save any open documents prior to pausing, just in case something goes wrong.