Wednesday, 7th January 2009
Stopping a job in the foreground, i.e the one actively displaying output to the terminal, is pretty simple.
Ctrl+C
Use the following command to start a program so that we can demonstrate how to stop jobs running. Documentation about the program is covered in the section about the internet.
$ lynx
Ctrl+C
Exiting via interrupt: 2
There is another method to stop jobs, just so you don't have to bring the job to the foreground to stop it. The kill command
allows any job to be stopped from the command line. Useful for stopping jobs which have hung or crashed but failed to terminate.
It requires an arguement to identify which job to stop, the job number with the percent sign, %2 identifying
the second job, can be used or if the process id of the job is known that can also be passed in, which is useful in the case where
a job in one terminal window fails to terminate and must be killed by opening another session, note jobs running in different
sessions cannot be seen by other sessions as jobs even when run by the same user.
Start lynx again:
$ lynx
Ctrl+Z
[3]+ Stopped lynx
$ kill %3
[3]+ Stopped lynx
$ fg
lynx
Exiting via interrupt: 15