DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Shell Scripting (http://www.daniweb.com/forums/forum113.html)
-   -   difference btw a process and a job (http://www.daniweb.com/forums/thread159920.html)

Trekker182 Nov 28th, 2008 6:53 pm
difference btw a process and a job
 
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

omrsafetyo Nov 28th, 2008 7:52 pm
Re: difference btw a process and a job
 
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".

Trekker182 Nov 28th, 2008 7:57 pm
Re: difference btw a process and a job
 
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.

eggi Nov 28th, 2008 11:48 pm
Re: difference btw a process and a job
 
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

Trekker182 Nov 28th, 2008 11:58 pm
Re: difference btw a process and a job
 
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.

eggi Nov 30th, 2008 2:51 am
Re: difference btw a process and a job
 
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

Trekker182 Nov 30th, 2008 12:42 pm
Re: difference btw a process and a job
 
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.

omrsafetyo Dec 1st, 2008 3:22 pm
Re: difference btw a process and a job
 
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.


All times are GMT -4. The time now is 10:03 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC