Suspending a Job
Two questions here, how do you suspend jobs and why would you want to suspend
jobs.
There are a couple of special commands that can be issued to programs using
the control key (ctrl) plus another key one of which results in the suspend request
being sent to the program. To demonstrate this and the reasons why we do this
use the following commands and key strokes to set up and suspend a few jobs.
Now before we suspend this job use the cursor keys to move down to the line
which reads:
* Reference:: MySQL Language Reference
Press return, now don't worry if you don't understand this, its explained fully
in the section on the info program, for the moment just follow the instructions
and if you go wrong just press '
q' to get out. On the next screen
go to the line that reads:
* Data Manipulation:: Data
Manipulation: 'SELECT', 'INSERT', 'UPDATE', 'DELETE'
and press return again. At this stage we're far enough and you can use the key stroke to suspend as given below.
Ctrl+Z
[2]+ Stopped info mysql
Earlier you were shown that you could use % followed
by a number to return to a job you'd suspended. We can use that here as well
but this time the number will be 2 since the suspended job we wish to return
to is number 2:
You should find that not only are you returned to the job but also to the exact
place where you were when you suspended the job. This remains true for all jobs.
Why is this useful? Lets say you were in mysql (database program) trying to perform
some task, instead of needing a reference book, you can suspend your current job
and check the reference for mysql in the info program. Once you have found whats
needed the info program can be suspended and you can return to the mysql program.
Where this is particularly useful is when you need a to follow a list of instructions
or need to return repeatedly to verify the different steps, each time you suspend
the job you will return to that point instead of having to stop one job start
another find what your looking for, stop and restart from scratch the initial
one.
We're finished with this info program at this point so time to quit.
Just as a final point when suspending jobs, when you suspend a job its referenced
as being stopped, and if you try to log out with any jobs suspended the shell
will inform you that you still have jobs that are suspended. Assuming that you've
been following from the start you should still have one job suspended, if not
create one and then suspend it. Then attempt to logout using the logout command
or if your using a terminal window on a linux desktop use the exit command instead.
$ logout
There are stopped jobs.
This is just a nice touch to let you know to go back and exit the programs
properly otherwise you run the risk of losing any data not saved.
Next we'll learn how to background jobs.