Download presentation
Presentation is loading. Please wait.
Published byNicholas Briggs Modified over 9 years ago
1
1 Day 10 Process Control
2
2 Running a program in the background Here’s a trick: You can actually log onto a UNIX server as many times as you want Try double-clicking on PuTTY a few times and log in every window You can run different things in different windows
3
3 Background For instance, you could run hangman in one window, elm in another, and have vi in another All appear to be running at the same time with no slowdown (usually)
4
4 More on Background Try running this command: primes 0 100 It will print out all prime numbers between 0 and 100 Now keep running primes over and over and add zeros to the 100 each time primes 0 10000
5
5 Running primes Eventually you will see that running primes takes longer and longer Try running this one: –primes 0 100000000 > /dev/null This will take quite a while to finish You cannot type at the shell while this is running
6
6 Running primes in the background One solution: run primes in one window and do something else in another Or…. Run primes in the background of just one window!
7
7 Background processes You can start a command in the background (you maintain control of the shell and can run new commands) Special character: & Example: –primes 0 100000000 > /dev/null &
8
8 Another way... You can also stop a process Command: CONTROL-Z You are given a job number: –[1]+ Stopped hangman The job number is in brackets
9
9 Stopped Jobs Jobs that are stopped can be brought back into the foreground Command: fg % Example: fg %1 Or they can begin running in the background Command: bg % Example: bg %1
10
10 You can also kill jobs CONTROL-C can only be used in the foreground Must kill background jobs Command: kill % Example: kill %1
11
11 Forget a job number? Command: jobs This will tell you job numbers for all running and paused jobs
12
12 Another Way You can also use a job’s pid (process ID) to kill it You can get the pid with: ps Then you can use kill: kill Example: kill 12994
13
13 Stubborn Processes You can force a process to die Command: kill -9 Example: kill -9 12994
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.