943,691 Members | Top Members by Rank

Ad:
Nov 28th, 2008
0

difference btw a process and a job

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Trekker182 is offline Offline
93 posts
since Apr 2008
Nov 28th, 2008
0

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".
Last edited by omrsafetyo; Nov 28th, 2008 at 7:53 pm.
Reputation Points: 13
Solved Threads: 9
Junior Poster in Training
omrsafetyo is offline Offline
58 posts
since Apr 2008
Nov 28th, 2008
0

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.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Trekker182 is offline Offline
93 posts
since Apr 2008
Nov 28th, 2008
0

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
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007
Nov 28th, 2008
0

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.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Trekker182 is offline Offline
93 posts
since Apr 2008
Nov 30th, 2008
0

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
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007
Nov 30th, 2008
0

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.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Trekker182 is offline Offline
93 posts
since Apr 2008
Dec 1st, 2008
0

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.
Reputation Points: 13
Solved Threads: 9
Junior Poster in Training
omrsafetyo is offline Offline
58 posts
since Apr 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: DOS 6.22
Next Thread in Shell Scripting Forum Timeline: Beginner in UNIX/Shell Script - Please help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC