Sometimes after you've started a job and placed it in the
background, you realize it is an incorrect process and you do not
want to run it. In this type of instance, you can destroy or kill
a job.
Suppose, you start this process:
$ lsf /* | sort > filenames& [1] 6112 |
then realize you do not want to list the full file system
(that is, you really didn't want to use *
in the command line), but rather, just the root directory, and decide
to kill the job. To kill the process, use the job's number, ([1]),
and type:
The kill
command kills the job and the %
metacharacter specifies the job number 1.
As shown above, you are returned to the prompt. Recall that %+
and %% perform
the same function as %1,
since it is the current job. If it was the previous job, use %-.
To see the status of the job, type:
$ jobs [1] + Terminated lsf /* | sort > filenames& |
The line following jobs
shows that the current lsf
job has been terminated.
If you log off the system while any of your processes are
running, whether in background or foreground, the jobs are destroyed
unless you use the nohup
command (see nohup(1) in the HP-UX
Reference for details).