cd ~/it244/ex
mkdir ex13
cd ex13
cp ~tsoro/course_files/it244_files/bother.sh .
./bother.sh
Control C
./bother.sh &
The number in brackets is the job number. The second number
is the process number of the first process in the job.
jobs
jobs
jobs shows you the job number of all running jobs, their
status, and the command line that created the job.
ps
ps
bother.sh is a simple script containing a loop that never ends.
Inside the loop, it sleeps for 5 seconds and then prints something.
When bother.sh calls sleep, it initiates a subprocess, which you
see beneath bother.sh in the listing.
fg
You don't have to supply a job number because there is only
background job.
Control Z
jobs
jobs
The job still exists, but it is suspended.
ps
ps
Both bother.sh and it's sleep subprocess are still there.
bg
Again, since there is no other job, you do not have to supply
a job number as an argument.
jobs again
jobs
The job is now in the background and has resumed running.
jobs to see the job number
jobs
kill %JOB_NUMBER
JOB_NUMBER is the number that the jobs command showed you.
jobs to see what happened
jobs
The job has been terminated.
./bother.sh &
ps to get the process number for bother.sh
ps
kill PROCESS_ID
PROCESS_ID is the process ID of bother.sh.
jobs to see what happened
jobs
The job has been terminated.
ps to see your running processes
ps
bother.sh and its subprocess are gone.