Breadcrumbs 
Learning >> Documentation >> Jobs >> Stopping jobs
 
Recent News
We're No 1!
We've reached the top! (Of Google!)
[ more ]
Firefox 3 Download Day
Firefox 3 has been officially released and is looking to set a world record for the most downloaded piece of software in 24hrs.
[ more ]
SSL Renewed
SSL cert has been renewed by the admin team.
[ more ]
Stopping Jobs
Stopping Jobs

Stopping a job in the foreground, i.e the one actively displaying output to the terminal, is pretty simple.

Ctrl+C

This is the combination of the two keys on your keyboard which sent an exit signal to the job running, provided the job is able to accept this and is able to handle it, the job should exit immediately.

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

Now use the stop command:

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


Then suspend it as shown before:

Ctrl+Z
[3]+ Stopped         lynx


Finally use the kill command:

$ kill %3
[3]+ Stopped         lynx


It doesn't exit straight away but try:

$ fg
lynx


Exiting via interrupt: 15

Don't forget to quit all remaining jobs running in the background as well before quitting. You can use the fg command to access the most recent job and if you've been following the commands in this section you should only have 1 instance each of man & info running and pressing q will exit out of these programs.