Last Updated: February 25, 2016
·
597
· jakebellacera

bash jobs

Problem: you are someone who opens new tabs in Terminal for each running application

Solution: jobs!

1. Run your program

$ bundle exec spork

2. Suspend it with ^Z

$ ^Z
  [1]+ Stopped          bundle exec spork

That's <kbd>Control</kbd> + <kbd>z</kbd>. The number in square brackets is your job number.

3. Run it in the background with bg

$ bg 1
  [1]+ bundle exec spork &

4. Bring it back to the foreground with fg

$ fg 1
  bundle exec spork

Bonus: running an app in the background automatically

Append your command with an ampersand (&)

$ rails s &

Bonus: listing available jobs with jobs

$ jobs
  [1]+ Running          bundle exec spork &
  [2]+ Running          rails s &