How to Pause & Resume an App or Process in Mac OS X

May 30, 2013 - 9 Comments

Terminal in OS X Need to quickly free up some processing power? You can do that easily by temporarily pausing and then later resuming any active process or application in Mac OS X. Technically, this is actually ‘stopping’ and ‘continuing’ a process, but a stop is not to be confused with the more aggressive killing or force quitting applications and thus the terminology of pausing or halting is often easier to differentiate the two.

This means you can take a process that is consuming 100% CPU and temporarily pause it while you do something else, then resume it when you are ready to let that process do it’s thing. This is achieved through a command line trick, and we’ll cover two different ways to do it by using the kill and killall commands with the -STOP and -CONT flags. Ideally you will have some comfort and knowledge with the command line before using this, but it’s certainly not necessary.


Before beginning, launch the Terminal app, found in /Applications/Utilities/, and also launch Activity Monitor, which is in the same folder.

Stop a continue a process from command line

How to Temporarily Suspend Stop a Process or App in Mac OS X

The basic syntax for suspending an application is as follows, where PID is the ID of the process you wish to pause:

kill -STOP PID

The PID is always a number, and every single process running on a Mac has an associated ID.

If you’re familiar with retrieving process ID’s, then you already know what to do using the above commands alone, but if not then that’s what we’ll cover next, and that’s why we launched “Activity Monitor”

Finding the PID & Halting the Associated Process

This is the more user friendly method, utilizing Activity Monitor:

  • From Activity Monitor, use the Search function in the upper right corner and type the application name you wish to suspend (e.g.: iTunes)
  • With the matching processes and/or app(s) visible, locate the process ID by looking under the “PID” column
  • Stop a process in Mac OS X

  • Add the matching PID to the aforementioned kill command, like so:
  • kill -STOP 3138

  • Note the CPU activity for that process ID is now at 0%, indicating the process has been paused (technically, stopped)

Don’t forget the PID, or better yet, don’t close the Terminal window quite yet, because that same PID is how you will resume the application to continue being able to use it again.

You will find the effect of stopping a process on CPU usage is dramatic, this screen shot demonstrates iTunes consuming 70% CPU while running it’s Visualizer, and the same iTunes process after it has been halted with the -STOP flag. The process has literally been stopped in its tracks:

Pause a process in Mac OS X to save CPU

Those with more command line knowledge may prefer to use ps rather than Activity Monitor, which is really quite easy:

ps aux |grep Name

Change “Name” to whatever the start of a process or application name is, locate the PID, and then put that into the kill command:

kill -STOP 92841

Whether you use Activity Monitor or ps to retrieve the PID is irrelevant, so long as you enter the correct process ID when using the kill command.

Note that trying to use an application that has been paused will almost always result in seeing the spinning beach ball of death, minus the CPU usage. Thus, if you want to use the app again, you must “resume” it.

How to Resume a “Stopped” Application or Process

Resuming a stopped or paused application is simple, just change the kill command slightly and use the same process ID that you retrieved from the previous steps:

kill -CONT PID

For example, to resume the iTunes app using the PID from earlier:

kill -CONT 3138

And now iTunes becomes usable again, minus the spinning wait cursor. Along with this comes a return to whatever level of CPU consumption existed earlier.

The screenshot below demonstrates this trick using both the kill and killall commands:

Pause and resume an app in Mac OS X

Using -STOP and -CONT with killall is essentially the same, but it has some limitations regarding names, and thus we covered the more direct method of using kill based on PID instead. Nonethless, let’s demonstrate this with killall too.

Stopping & Continuing Applications by App Name

If you know the application or exact process name, you can also use the ‘killall’ command with the -STOP flag to halt processes. This can be easier for apps that are simple to identify by a name, but it has limitations when it comes to working with processes with complex names, or for pausing a specific process that has duplicate processes with the same name (like a specific Chrome tab or window mixed in with many “Google Chrome Renderer” processes), and thus we covered the PID approach first because it’s much more direct.

The basic halt command with killall is as follows:

killall -STOP AppName

Not sure what the app name is? Use ps and grep:

ps aux |grep AppName

For example, you could grep for “Chrome” to find all processes with “Chrome” in the name:

ps aux|grep Chrome

Or you can just target the process with a specific app name like so:

killall -STOP -c "Google Chrome"

Resuming processes and apps with killall is a matter of changing the flag from -STOP to -CONT, everything else is the same:

killall -CONT AppName

For example, to resume the application with a long name:

killall -CONT -c "Google Chrome"

Again, the app/process will continue to function as usual, and CPU usage will return to where it was before being paused.

Apps or processes with no spaces in their name can be impacted directly by killall without any additional flags or indicators, like iTunes.

.

Related articles:

Posted by: Paul Horowitz in Command Line, Mac OS, Tips & Tricks

9 Comments

» Comments RSS Feed

  1. caue rego says:

    if you happen to have many processes paused, you could simply use `kill -CONT -1` to unpause them all, as explained here

  2. simon says:

    just worked this out for terminal hanging.
    download iterm2 and use it the kill -CONT pid for terminal
    restarted a 10 TB copy from was device where the acls have gone wonky

  3. Zack says:

    Wow this actually worked for me, i’ve been on a long quest to get a ‘pause button’ for emulated windows apps on a Mac, the app actually pauses now.. yet there is a ‘beach ball’ of death that appears, which seems eerie, even though the game paused, it almost seems like some hidden process might be fighting back which could be bad for cpu

    • Zack says:

      i read further down and

      killall -STOP -c “wine”
      killall -CONT -c “wine”

      work even better for me. i was so happy with the pause function

      yet i used it a few times and now i’m getting more beach balls lag and my fan is going off. i haven’t had this problem in a long time, the pause seems to be causing some very power taxing hidden error. wine/windows probably thinks my pause is an error and is desperately fighting back, i’ve found no other way to pause though

      • Hi Zack,

        Thanks for telling us your experience – I was worried about the implications of using this too frequently, and your account has given me pause. Do you have any followup knowledge to impart, or did you stop using this feature after the above issues.

        Scott

  4. humor4fun says:

    do not ever stop a Terminal process. you will not be able to resume it.

    • anro says:

      That is incorrect, you can resume a paused terminal by unpausing it, or by resuming the proces id with screen -r

    • rosie says:

      This is exactly what I use to stop and start my terminal processes when they start to overheat my computer. Works like a charm!

  5. Michael Klement says:

    I suggest using utility `pkill` instead: it allows you to search for processes with regular expressions (the companion utility `pgrep` simply returns PIDs).

    Example: To only suspend Google Chrome itself – and not also its helpers – use:

    pkill -STOP ‘^Google Chrome$’

    Note that by adding `-f` the regular expression is matched against the entire command line – including parameters.

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site