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

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".

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.

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

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.

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

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.

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.

This question has already been answered. Start a new discussion instead.