Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Latest commit

 

History

History
25 lines (17 loc) · 1.75 KB

120-job.md

File metadata and controls

25 lines (17 loc) · 1.75 KB

Jobs

This section deals with processes. You will learn how to manage programs in the console. Especially, you will move them to back- and foreground and learn how to force terminate a blocked program.

Exercise 1: fg, bg, &, top, htop, kill, pkill, killall

a) Install htop if you do not already have it. b) Navigate to the jobs directory. c) Run the infiniteloop.sh script. Now your terminal should become unresponsive. d) Find a way to stop the script without closing the window.

Now we want to learn how to kill processes running in the background. This is helpful when you have programs that have hung themselves up and have to be shut down. Collectively, the commands you will be using are known to provide "process control", that is, functionality similar to task managers known from Windows/OS X. So we will basically learn how to use Ctrl+Alt+Delete under Linux ;)

e) Run the script used in exercise c) again, but in a way such that it becomes a background job. f) Now turn it into a foreground job while it's still running. Do you notice a difference? g) Now move it back to be a background job. Can you still kill it as before? h) Try and find out the PID (process id) of your started process (you might want to do this in a different terminal). i) Use the kill command with the PID to get rid of the process. j) Finally, start 3 instances of infiniteloop.sh, each of them running in the background, then use the jobs command. Now kill them in the following order, as presented by jobs: 2, 1, 3

Exercise 2: ps, kill, killall, pkill

Do the same as above but this time without using top or htop and use a different method to kill it. You also do not need to do all that background foreground stuff again.

Can you find the parent of the process you started?