difference btw a process and a job

Thread Solved

Join Date: Apr 2008
Posts: 88
Reputation: Trekker182 is an unknown quantity at this point 
Solved Threads: 0
Trekker182 Trekker182 is offline Offline
Junior Poster in Training

difference btw a process and a job

 
0
  #1
Nov 28th, 2008
I'm reading up on jobs and processes in UNIX and was a little confused. A processes is just something that executes and then dies right away, like a grep command issued from the shell, right? It started, did what it was supposed too, outputs the info and then dies so a total of one process was started. In the case of grep, no jobs had a chance to get started since I type in jobs and nothing comes up.

Now, if I go into VI, enter some text and hit control-Z and then jobs, there it is. A job is a process but is a process that is suspended in the background while in the middle of doing whatever it was supposed to do.

Am I on the right track?

thx
Last edited by Trekker182; Nov 28th, 2008 at 6:55 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 58
Reputation: omrsafetyo is an unknown quantity at this point 
Solved Threads: 9
omrsafetyo omrsafetyo is offline Offline
Junior Poster in Training

Re: difference btw a process and a job

 
0
  #2
Nov 28th, 2008
A job is a process running in the background.

E.g.

./myscript.sh &
[1] myscript.sh 96243

A job relates to a command run from a terminal. It is attached to a terminal session. A command can be run in the background if it doesn't require any user input, and you want to continue running other commands in the foreground.

For instance, on an AIX/Informix system, I usually do something like

# nohup dbexport my_database &

The nohup redirects any output to a file (nohup.out) and the ampersand (&) puts the process in background mode. This allows me to continue working while my export completes.

The "job" is any process that is running in a background mode.

Crtl-Z also stops a process and puts it in the background - which is why "jobs" displays your vi session. You can recall your job with "fg", or you can tell a stopped process to continue in the background with "bg".
Last edited by omrsafetyo; Nov 28th, 2008 at 7:53 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 88
Reputation: Trekker182 is an unknown quantity at this point 
Solved Threads: 0
Trekker182 Trekker182 is offline Offline
Junior Poster in Training

Re: difference btw a process and a job

 
0
  #3
Nov 28th, 2008
Ok thanks.

So when I do commands like grep, awk, who, commands that display immediate results, they are not referred to as jobs but as a single processes that starts and ends with you getting the bash prompt again. There isn't any opportunity for me to hit CTRL-Z to push it to the background and then type jobs and see it come up.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: difference btw a process and a job

 
0
  #4
Nov 28th, 2008
Hey there,

process/job - terms are sometimes misused or mixed up in regular reference to them, in everything from regular conversation to official text books.

For awk, who, etc, you can run any process/job in the background without having to hit ctrl-Z by just starting them in the background, like:

awk &

As an oversimplified example

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 88
Reputation: Trekker182 is an unknown quantity at this point 
Solved Threads: 0
Trekker182 Trekker182 is offline Offline
Junior Poster in Training

Re: difference btw a process and a job

 
0
  #5
Nov 28th, 2008
So if you didn't add the & to keep it in the background, then it would just be a normal process, right?

I'm just trying to get a better understanding since my book doesn't really do a good job separating them.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: difference btw a process and a job

 
0
  #6
Nov 30th, 2008
Actually, either way it's just a normal process. I guess the distinction to be made is that "job control" manages processes and refers to them as jobs. Every job is a process (possibly more than one). Really, the term "job" is probably what's confusing for you.

Best wishes,

Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 88
Reputation: Trekker182 is an unknown quantity at this point 
Solved Threads: 0
Trekker182 Trekker182 is offline Offline
Junior Poster in Training

Re: difference btw a process and a job

 
0
  #7
Nov 30th, 2008
Yah, originally I thought that they were both two separate things but now I understand that a process is just that, one process but a job can and often does include multiple processes running together in the foreground or background.

Thanks.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 58
Reputation: omrsafetyo is an unknown quantity at this point 
Solved Threads: 9
omrsafetyo omrsafetyo is offline Offline
Junior Poster in Training

Re: difference btw a process and a job

 
0
  #8
Dec 1st, 2008
no - a job is still a single process. Jobs in fact are controlled by their Process ID.

eggi has it right - basically the only "difference" is that you can manage a job through the job manager commands - fg, bg, jobs, etc.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC