Some simple assumptions: the syntax is for the C-shell (csh or tcsh), not bash or sh. sudo is a command that calls a program as root.
If one wants to send a job to the background in Unix, most people know that you append '&' to the command:
It is in the background, as you can see with the command:
[1] is the job number ([1], [2], [3], etc...). Don't confuse the job number with the PID 23035 (Process ID number). You can bring the job back to the foreground with fg %1 (or just fg):
But what do you do when you have the job in the foreground and you want to send it to the background (i.e. you are "stuck" because you forgot the &, or you simply changed your mind and now you want the job in the background)? Ctrl-C will kill the job, and you don't want that. If you type Control-Z, the job gets "suspended" which means, it is in not in the foreground anymore, but it is not running either. For instance if you type:
then Control-Z, the shell will respond with:
Listing the jobs will give you the following:
To make it run again, you have two options: use the bg command (which means "make it RUN in the background" or "change its status from suspended to running):
Also, and that I did not know until recently, you can use kill -CONT <pid>, where <pid> is the process id number. In this context, kill is actually a pretty bad command name: it does not "kill" the program. It sends a signal to the program (which, if you don't use -CONT(inue), will be by default -TERM(inate)). Similarly, you can send a -STOP signal to suspend a job that is already in the background.
For instance, if you are running a lengthy and CPU consuming job (or disk consuming job), like:
You can see it running in the background:
where [1] is the job number and 21035 is the pid. By issuing:
you will suspend the job, until you use the bg command with the job number, or kill -CONT with the process ID number.
Posted by dccote at January 3, 2004 11:46 PM