Quick Tip: Pause any process you want in Linux

 mike@krusty:~$ pidof ffmpeg
 mike@krusty:~$ sudo kill -STOP 22730
 [sudo] password for mike:
 mike@krusty:~$ sudo kill -CONT 22730

Holy crap, how come it took so long for me to figure out you can pause a running process in Linux and restart it later? I was looking at the manual page for the kill command (man kill) when I started wondering what the CONT option is used for. It turns out that it is paired with the STOP option (and a couple of others) which can be used to pause a running process. Here’s a quick rundown of the process:

  1. Find the PID of the process using the ‘pidof’ command
  2. Pause the process using that PID (22730 for example): sudo kill -STOP 22730
  3. Go about your business
  4. Restart the process when you’re ready: sudo kill -CONT 22730
What can you use this for? Well, if you’re doing something processor intensive, like transcoding video, you might want to regain your CPU power for a quick task. This lets you do that.

3 thoughts on “Quick Tip: Pause any process you want in Linux

  1. Certainly useful, but usually if you have the programs stdI/O open, a ^Z would accomplish this in a much neater way (If I’m not mistaken) – you can resume by typing either ‘bg’ for running it in the background without the stdI/O or ‘fg’ to get it back

    • You’re right. But I have a lot of automated processes, like automatic transcoding of over-the-air television shows. If I want to play Portal 2 on Steam running under Wine (processor intensive) it’s nice to be able to pause FFMPEG and start it back up again once I’m done gaming.

      • True that, it certainly has it’s uses. Especially if you don’t have the stdout available somewhere – like you usually do not when it’s a background job.

Leave a Reply