Please note that LinuxExchange will be shutting down on December 31st, 2016. Visit this thread for additional information and to provide feedback.

2
1

If I send a task to the background with ctrl+z, is it stopped?

If I type bg 1, will it keep going?

I'm just a little confused as to how background processes work. jobs and bg and fg don't have man pages.

If I have a jobs output that looks like this:

kevin@orangebox:~$ jobs
[1]-  Stopped                 htop
[2]+  Stopped                 top

What do the pluses and minuses mean?

asked 27 Jul '10, 23:51

Klink-a-dink-dink's gravatar image

Klink-a-dink...
233
accept rate: 0%

Also, "jobs -l" will also show you the process ID without having to use ps

(02 Aug '10, 19:18) Andy



bg and fg are built into the shell. Hence their man page (assuming you are using bash) is part of bash(1). Look for the section labelled "Job Control". An online version can be found at: http://linux.die.net/man/1/bash

If you stop a job using Ctl-Z, all you have to do is type "fg" or "bg" to restart it in the foreground or background, provided it is the "current job" (labelled with a "+".)

If you want to see all of your running and stopped jobs in a shell, type "jobs". It lists them with a job number and priority. The most current job is listed with a "+", all other background jobs are listed with "-".

Then you can type %1 (for instance) to restart job number 1 in the foreground. (It's a shortcut for "fg %1".)

Reading the bash(1) man page takes effort, but there's tremendous power available in the shell if you just know how to use it. That makes reading the man page well worth the effort.

Good Luck.

link

answered 28 Jul '10, 00:17

DBA's gravatar image

DBA
2264
accept rate: 23%

Thanks!

Does this mean I can only have one process running in the background at a time, though?

(28 Jul '10, 00:42) Klink-a-dink...
3

No, you can put multiple processes into the background.

(28 Jul '10, 01:06) rfelsburg ♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×5
×4
×3

Asked: 27 Jul '10, 23:51

Seen: 1,701 times

Last updated: 28 Jul '10, 00:17

powered by OSQA