cd ~/it244/ex
mkdir ex13
cd ex13
cp ~ghoffman/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
psbother.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.
fgYou don't have to supply a job number because there is only background job.
Control Z
jobs
jobsThe job still exists, but it is suspended.
ps
psBoth bother.sh and it's
sleep
subprocess are still there.
bgAgain, since there is no other job, you do not have to supply a job number as an argument.
jobs
againjobsThe job is now in the background and has resumed running.
jobs
to see the job numberjobs
kill %JOB_NUMBERJOB_NUMBER is the number that the
jobs
command showed you.
jobs
to see what happenedjobsThe job has been terminated.
./bother.sh &
ps
to get the process number for bother.sh ps
kill PROCESS_IDPROCESS_ID is the process ID of bother.sh.
jobs
to see what happenedjobsThe job has been terminated.
ps
to see your running processespsbother.sh and its subprocess are gone.