LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What's the difference between ps -A and jobs... (https://www.linuxquestions.org/questions/linux-newbie-8/whats-the-difference-between-ps-a-and-jobs-719309/)

trist007 04-15-2009 10:42 AM

What's the difference between ps -A and jobs...
 
Aren't they both processes running in the background? Why is it that you can fg bg process listed in jobs whereas in you can't fg and bg processes listed in the ps -A output?

indienick 04-15-2009 11:18 AM

jobs, fg and bg is a separate set of programs than ps.

"Jobs" are more user-controlled, whereas ps is the age-old tool for listing processes. I highly suggest reading the man pages: ps(1) however, it seems jobs, fg and bg do not have any sort of documentation on the Debian Lenny server I am running.

maresmasb 04-15-2009 12:42 PM

Information about jobs, bg and fg is part of the BASH_BUILTINS(1) man page. Typing jobs, bg or fg will bring up that man page automatically (at least it does that on Fedora).

ps -A does simply list all processes. No wizardry there.

jasohl 04-15-2009 01:38 PM

ps just lists all processes running on the system.
jobs is very different. It is a BASH built-in. It shows jobs that a user or script explicitly put in the background.

press Ctrl-Z while a process is running to suspend it to the background.
use bg jobnumber to resume the process (in the background)
you can start a job in the background by appending a &

Code:

$sh somescript.sh &
the script will start in the background and you will continue to have a bash prompt.
any job will stay in the BG until it finishes or is brought the the fore using fg jobnumber

this allows you to start and control multiple tasks

You can read more:
BASH Job Control
BASH_BUILTINS


All times are GMT -5. The time now is 02:54 AM.